Friday, 17 June 2016

Wait until element disappears in Selenium

Below code waits until element disappears in Selenium.

public void waitUntilElementDisappear(By by){
        for (int i=0;i<=60;i++)
        {
            if (checkElementExists(by))
                sleep(1000)
            else
                break;
        }
    }


public boolean checkElementExists(By by, int seconds){
        boolean result=false;
        try {
            driver.manage().timeouts().
implicitlyWait(seconds, TimeUnit.SECONDS);
            driver.findElement(by);
            result = true;
        }catch (org.openqa.selenium.NoSuchElementException ex){
            result = false;
        }
        finally {
            driver.manage().timeouts().
implicitlyWait(20, TimeUnit.SECONDS);
} return result; }


What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

Contributors