priyanka
priyanka

Reputation: 1

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

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?

Upvotes: 0

Views: 34

Answers (1)

Bhairu
Bhairu

Reputation: 134

    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.
    }

Upvotes: 0

Related Questions