How to wait until the page freezes in Selenium WebDriver?

We have the following logic in the frontend - so when a new page is loaded, the screen is automatically scrolled to a specific section, and I have a script that clicks on a specific element at that time. Hence, while this movement occurs, the following error appears due to selenium clicking on the wrong element:

"Element is not clicked at (x, y). Another element will get clicked ..."

I added a simple dream, but this solution is not very good. Does anyone have any idea how to wait for the page to freeze - when auto-scrolling is complete?

+3


source to share


1 answer


f you know which element you are scrolling through (the element that is at the top of the browser viewport when you are done scrolling), you can wait for the y property of the navigator representing that element to be zero. Below is an example that you can paste into the groovy console that navigates to the page and then scrolls to an element using its id in the url (I know there are no expectations here and the scrolling is not animated, but I just want to show how this property can be used to achieve the desired wish): I am not familiar with protractor, so you will need to adjust the block syntax accordingly.



waitFor { 
  elementWeScrollTo.y == 0 
}

      

0


source







All Articles