문제

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