Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

So far I used 2.45.0 version of selenium and all my waits were done in this way:

WebDriverWait wait = new WebDriverWait(webKitUtility.getWebDriver(), 5);

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("role")));

But I updated selenium to 3.1.0 and I am getting the error:

"The method until(Predicate) in the type FluentWait is not applicable for the arguments (ExpectedCondition)"

I see that from 2.45.0 to 3.1.0 some things are deprecated. I am trying to investigate what is the best way to do it now, but I am not sure. Most of the things I'm finding on google are old information explaining the same way I was using so far.

1 Answer

0 votes
by (62.9k points)

Try adding the following dependency to the maven pom.xml, remember that the order of dependencies does matter:

<dependency>

      <groupId>com.google.guava</groupId>

      <artifactId>guava</artifactId>

      <version>21.0</version>

</dependency>

For example:

public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver", "/Users/me/geckodriver");

    final WebDriver driver = new FirefoxDriver();

    driver.get("https://www.google.com");

    final WebDriverWait wait = new WebDriverWait(driver, 5);

    final By feelLuckyXpath = By.xpath("//div[@class='jsb']/center/input[@type='submit' and @name='btnI']");

    wait.until(ExpectedConditions.visibilityOfElementLocated(feelLuckyXpath)).click();

    driver.close();

}

Hope this helps!

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium certification!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...