I am getting the following error while compiling selenium automation application using java and gradle version 3.4.
Error:
method until in class FluentWait<T> cannot be applied to given types;
return getWebDriverWait().until(ExpectedConditions.elementToBeClickable(GOTO_ICON));
^
required: Function<? super WebDriver,V>
found: ExpectedCondition<WebElement>
reason: cannot infer type-variable(s) V
(argument mismatch; ExpectedCondition<WebElement> cannot be converted to Function<? super WebDriver,V>)
where V,T are type-variables:
V extends Object declared in method <V>until(Function<? super T,V>)
T extends Object declared in class FluentWait
Build.gradle
compile 'io.appium:java-client:3.1.0'
compile 'com.applitools:eyes-selenium-java-jersey1x:2.29'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.46.0'
compile 'org.seleniumhq.selenium:selenium-firefox-driver:2.52.0'
compile 'org.seleniumhq.selenium:selenium-ie-driver:2.52.0'
Source code:
By GOTO_ICON = By.id("GoTo");
String windowContentLoaded = "//*[@id=\"windowContentLoaded\"]";
public WebElement getGoToHeader() {
waitForPageToBeLoaded();
return getWebDriverWait().until(ExpectedConditions.elementToBeClickable(GOTO_ICON));
}
public void waitForPageToBeLoaded() {
sleepSeconds(3);
getWebDriverEx().waitForInvisibleElement(By.xpath(windowContentLoaded));
return;
}
Not sure what would be the reason for the error in Selenium 2.46.0, however I've exactly the same error when switching from version 3.x to version 4.x.
It might not help the OP solve the problem, however I'm posting a solution for people coming here when searching for the same exception.
In the recent version of Selenium framework the getWebDriverWait().until()
interface had changed a bit:
Now it accepts functional interface, with one argument (WebDriver
) and return value depending on the WebDriverWait
implementation, which in most cases is ExpectedConditions
.
Try changing your code to:
public WebElement getGoToHeader() {
waitForPageToBeLoaded();
return getWebDriverWait().until(
webDriver -> ExpectedConditions.elementToBeClickable(GOTO_ICON).apply(webDriver)
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With