What is the equivalent code of selenium.waitForPageToLoad("30000") in Selenium WebDriver?

StackOverflow https://stackoverflow.com/questions/18378533

Вопрос

The following is the java code to wait for a page loading in Selenium RC:

selenium.waitForPageToLoad("30000");

What is the equivalent java code in Selenium WebDriver?

Это было полезно?

Решение

2 approaches:

  1. If you need to wait exactly 60 sec you could use Thread.sleep(60000)

  2. If you want to make sure that the page is loaded (it could be less than or greater than 60 sec) I would recommend the below approach:

Identify an element in the landing page & wait for it to be clickable. You are then sure that the page has been loaded.

WebDriverWait wait = new WebDriverWait(driver,120);
wait.until(ExpectedConditions.elementToBeClickable(By.id(id)));

WebDriver waits for a max of 120 sec. for the element to be clickable. If the element is clickable before that, your test would progress.

Другие советы

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top