Selenium webdriver explicit wait

后端 未结 7 1504
无人共我
无人共我 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:56

    public static void clickOn(WebDriver driver, WebElement locator, int timeout)
     {
            new WebDriverWait(driver,timeout).ignoring(StaleElementReferenceException.class).until(ExpectedConditions.elementToBeClickable(locator));
            locator.click();
    
        }
    

    Call the above method in the main method then we will get explicitly wait functionality.

提交回复
热议问题