Selenium webdriver explicit wait

后端 未结 7 1495
无人共我
无人共我 2021-01-03 10:21

I\'m writing some automated tests for using the selenium chrome driver. I trying to write a reusable method that will explicitly wait for elements to appear and then call th

7条回答
  •  臣服心动
    2021-01-03 10:40

    Just use this method.I hope it will work perfectly.

    public void waitForElement(String item) {
        WebDriverWait wait = new WebDriverWait(driver,30);
        WebElement element =  wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("item")));
    }
    

    Then call the method :

    waitForElement("new-message-button");
    

提交回复
热议问题