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