How to add explicit wait in PageFactory in PageObjectModel?

前端 未结 2 1828
感情败类
感情败类 2020-11-30 15:37

I have added hardcode wait thread.sleep() in my below code. How to use explicit wait. I want to wait till \"username\" WebElement appear. My program is working

2条回答
  •  感动是毒
    2020-11-30 16:14

    You have two options:

    1- You can use implicity wait while initializing the driver.

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

    2- Use explicty wait for the username field only:

    WebDriverWait wait = new WebDriverWait(driver,30);
    WebElement element = wait.until(
                        ExpectedConditions.visibilityOf(By.id(identifier)));
    

提交回复
热议问题