0

Our app uses Masonry grid layout. After page_A opens, the tiles keep moving for a second or two.

The test case is: open the page_A and click on the button which opens page_B.

While clicking the button I get either element click intercepted exception or nothing happens. Which I assume the button gets clicked but no event has fired, because it is too soon, maybe not all the functions have finished loading.

I tried explicit waits with ExpectedConditions.presenceOfElementLocated and ExpectedConditions.elementToBeClickable but I get results mentioned above.

How to solve this without Thread.sleep?

Preferably I would like to not use the second loading page_B (check the url or elements on page_B) as a criteria since it is a slow loading page and it has other problems.

Is there a way to know if the click was "successful", like if it has fired an onClick action, or started a function (I am not very good at JS).

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

Masonry has an event system. You could bind an layoutComplete event to set a global variable to true and poll that with the WebDriver JavaScriptExecuter.

This answers also explains how to use the JQuery.active state to monitor if the page is still working on rendering. Masonry seems to be often used with jQuery, so maybe that is a possible solution.

Waiting for a state with the JavaScriptExecuter is a bit complex. As an alternative in the past I have created a waitMethod that tries to click on an element, which waits for an expected new element for some milliseconds, if the new element does not show, try and click again.

waitForElementToShowAfterClick(By elementToClick, By elementToWaitFor, milliSecondsToWait = 1000, timesToRetry = 3) {
   // implementation
   return elementToWaitFor
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.