I currently have the following setup, but I'm not sure that my waits (Implicit and pageLoadTimeout) are working. Is this the proper implementation? By putting it in the @Before("@setup"), does it work for every Scenario or Step Definition run? Will the driver wait accordingly, everytime I call a @Given, @When..etc?
@Before("@setup")
public void setUp() {
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
}
Why is it necessary to assign a WebElement to the following wait , what does WebElement element receive? Is this the right implementation? -
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(id)));
boolean status = element.isDisplayed();
You only need to wait for page load in your case , and your Implementation is fine. @ Before is one of the Cucumber Hooks and it means your method gonna run before each Scenario. I suggest to use fluent wait instead of webdriverwait and here is why:
When using the FluentWait instance:
For instance:
Hope I helped.