selenium
selenium

Reputation: 55

implicitlyWait() is not working

    String baseURL = "http://output.jsbin.com/osebed/2";
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get(baseURL);

    Select muldrpdwn = new Select(driver.findElement(By.id("fruits")));

    muldrpdwn.selectByVisibleText("Banana");
    //muldrpdwn.selectByIndex(3);
    muldrpdwn.selectByVisibleText("Orange");
    muldrpdwn.selectByVisibleText("Apple");

    driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS) ;

    muldrpdwn.deselectAll();

I want to select multiple text and wait for 10 seconds and the deselect them all. selection and deselection is working fine. But both are happening like there is no wait inserted which is not as I have inserted 10 seconds wait. What's wrong?

Upvotes: 0

Views: 2107

Answers (1)

Guy
Guy

Reputation: 50809

Implicit wait is not Thread.sleep(). It's being defined one time, and it will cause the driver to wait up to 10 seconds for the elements to exists in the DOM when trying to locate them (using driver.findElement).

From WebDriver: Advanced Usage

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available

You can use explicit wait with expected conditions to wait for certain condition. If you want to wait full 10 seconds regardless (NOT recommended) use Thread.sleep(10000).

Upvotes: 1

Related Questions