Note if you are using Maven that order of the dependencies do matter.
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();
}
this code works fine with the following maven dependencies:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
</dependency>
but it may fail with reordered one:
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.8.1</version>
</dependency>
In this case because the google-api-client
contains:
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
as dependency which shadows the guava
lib in the selenium
lib.
In this case the error is:
no instance(s) of type variable(s) V exist so that ExpectedCondition<> ...
method until in class org.openqa.selenium.support.ui.FluentWait cannot be applied to given types;
required: java.util.function.Function
found: org.openqa.selenium.support.ui.ExpectedCondition
reason: cannot infer type-variable(s) V
(argument mismatch; org.openqa.selenium.support.ui.ExpectedCondition cannot be converted to java.util.function.Function)