Selenium Webdriver clicks on button on pop-up but fails to load next page

26 Views Asked by At

I have used implicit and explicit wait before clicking on button with condition like wait.Until(ExpectedConditions.elementToBeClickable(Webelement)), I am not getting element not interactable exception. driver clicks on button but fails to load the next page. Execution run properly in debug mode but not in actual run.

If I use thread.sleep method before click then working properly. As use of thread.slepp is not recommended any alternative is there for this?

1

There are 1 best solutions below

0
Bhairu On
    Simple, use the for loop and this loop will running till you getting the desired element/page.

    String url=driver.currentURL();
    for(int i=0;i<=100;i++)
    {
    if(url.equalsTo(Mention the expected page URL))
    {
//here it breaks the loop if the expected page URL is matched
    break;
    }else
    {
    driver. navigate.Refresh(); or click the element that will be taking you to the next/expected page.
    }