+13 votes
in Software Testing by (1.1k points)
edited by
I have to click on a element which come on a page after loading page,So how can i wait till load element in next page?

1 Answer

+2 votes
by Expert (4.6k points)
edited by
Best answer

For webdriver wait till the load an element ,you can use implicitlyWait But i recommend you to use ExpectedConditions

implicitlyWait: driver.manage().timeouts().implicitlyWait(130, TimeUnit.SECONDS);

ExpectedConditions :    WebElement element = (new WebDriverWait(driver, 1)).until(ExpectedConditions.presenceOfElementLocated((By.ID(ELEMENT_ID_HERE))));

by (1.1k points)
Thanks ExpectedConditions works but can you tell me if i want to decide the time till then driver will wait?
by Expert (4.6k points)
yah here WebElement element = (new WebDriverWait(driver, 3)).until(ExpectedConditions.presenceOfElementLocated((By.ID(ELEMENT_ID_HERE))));
here i have changed time 1 to 3 , so i think you got the point.
by Expert (5.9k points)
i also recommend you to use  ExpectedConditions

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated