Forum Discussion

amosh's avatar
amosh
Occasional Visitor
5 days ago

Clicking on Button while page is still scrolling

TestComplete is trying to click on web page buttons while the screen is still scrolling the object into view.  This is causing scripts to fail as it's either now clicking the wrong button or clicking where the button used to be but no longer is.  If I put a hover before the click it fixes the issue, but that will be a lot of extra steps in every script to hover before clicking any button.  Is there a delay I can set to have it not click the button while still scrolling into view?

3 Replies

  • scot1967's avatar
    scot1967
    Icon for Champion Level 1 rankChampion Level 1

    Hello amosh,

    I am a bit confused by your question.  I don't know of anything you can do in this case that won't involve adding steps to your code.  There may be better ways to handle the scroll delay however. 

    There is a simple static delay action and there are object property state based delays you can look into but each will require some code. 

    The WaitProperty method should do the job without requiring you to loop or guess how long to wait before attempting to click the button. 

    https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/waitproperty-method.html

     
    ... If you find my posts helpful drop me a like! 👍 Be sure to mark the best answer if you get one to help others out and to credit the one who helped you.  😎

     

     

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 1 rankChampion Level 1

    While page is still loading and displaying objects, there will be a high chance of attempting to click on a moving target. 

    The correct way to go about it, is to wait for the page to finish loading and than to wait for last object to be ready using its properties (exists enabled and visibleonscreen).
    https://support.smartbear.com/testcomplete/docs/app-testing/web/common-tasks/waiting-for-pages.html 

    Even-though your hover over work-around solves the issue, it does not guarantee it on each attempt. 

    P.S. if you like a post click on like and if it solves your problem mark it as a solution.

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Using the latest version of TestComplete, there seems to be an issue with scrolling. When using either Click() or ClickButton(), the scrolling doesn’t seem to scroll properly and is not consistent. When using the browsers Dev Tools, scrolling is always fast and consistent.

    The workaround is to use the buttons method scrollIntoView() then perform the click action.

    I also suggest you open a ticket via https://support.smartbear.com/testcomplete/message/ as Click() and ClickButton() methods should ideally scroll the button into view before performing a click action.