0

Can any one let me know how and where to implement Explicit Wait in POM frameowrk?

I mean, where should i implement explicit wait code? In POM classes or in Test Case classes?

since now, i have implemented the EW code line in POM class and within the constructor body, below code

public RegistrationPage (WebDriver driver)
    {
        PageFactory.initElements(driver, this);
        new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOf(GenderRadioButton));
    }

This worked fine for me, but not 100% sure whether or not this is a correct place to implement Explicit wait, need some insight on this plz

--- Ram

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ram
  • 19
  • 3
  • 1
    Possible duplicate of [Replace implicit wait with explicit wait (selenium webdriver & java)](https://stackoverflow.com/questions/45712431/replace-implicit-wait-with-explicit-wait-selenium-webdriver-java) – undetected Selenium Nov 15 '17 at 04:24

1 Answers1

1

You could try with this:

public RegistrationPage (WebDriver driver, int timeOutSeconds)
{
    driver.manage().timeouts().implicitlyWait(timeOutSeconds, TimeUnit.SECONDS);
    PageFactory.initElements(driver, this);
    new FluentWait<WebDriver>(driver)
            .withTimeout(timeOutSeconds, TimeUnit.SECONDS)
            .pollingEvery(RETRY_TIME, TimeUnit.SECONDS)
            .ignoring(NoSuchElementException.class)
            .until(ExpectedConditions
                    .visibilityOf(By.xpath(xpath)))
   driver.manage().timeouts().implicitlyWait(timeOutSeconds, CLASS_VARIABLE_IMPLICIT_TIMEOUT);
}
j.barrio
  • 1,006
  • 1
  • 13
  • 37