Saturday, November 12, 2022

Selenium - Explicit wait

 This post is not about explicit wait concept in Selenium. But about how we could convert standard explicit wait command to an action method.

So our standard command set is like this:

	WebDriverWait wait = new WebDriverWait(driver,Duration.ofSeconds(5));
	wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(".mb-3")));

Lets make the action class;

public void waitExplicity(By findBy) {
	WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
	wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(findBy));																									
}

This is a reusable method and therefore we should maintain it within the Abstract Components of our test framework.

(btw, hope you noticed the By locator being sent into wait.until as a parameter. The child class which will be extending the AbstractComponent class should set the value for this.)

No comments:

Post a Comment

Featured

Selenium - Page Object Model and Action Methods

  How we change this code to PageObjectModel and action classes. 1 2 3 driver . findElement ( By . id ( "userEmail" )). sendKeys (...

Popular Posts