Wait for page load in Selenium

后端 未结 30 2510
攒了一身酷
攒了一身酷 2020-11-22 07:12

How do you make Selenium 2.0 wait for the page to load?

30条回答
  •  失恋的感觉
    2020-11-22 07:59

    Use implicitly wait for wait of every element on page till given time.

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

    this wait for every element on page for 30 sec.

    Another wait is Explicitly wait or conditional wait in this wait until given condition.

    WebDriverWait wait = new WebDriverWait(driver, 40);
    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
    

    In id give static element id which is diffidently display on the page, as soon as page is load.

提交回复
热议问题