问题
I am novice to Selenium and trying to walk through some code. It uses Explicit Wait as below functions in Utils.java file.
public static void waitForElement(WebElement element){
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(element));
}
When I compile it gives the error :-
The method elementToBeClickable(By) in the type ExpectedConditions is not applicable for the arguments (WebElement)
回答1:
It is very clear from the error message that the method
ExpectedConditions.elementToBeClickable()
can accept only the type By
. you cannot directly pass a web element as a parameter to the method.
have a look at https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html to know the list of expectedconditions and their parameters.
回答2:
The method elementToBeClickable(By) in the type ExpectedConditions is not applicable for the arguments (WebElement)
It looks like you're using old version of selenium <= 2.37.0 where ExpectedConditions.elementToBeClickable
accept only By
object as a parameter.
But from selenium version >= 2.38.0 ExpectedConditions.elementToBeClickable accept By
as well as WebElement
object as parameter.
I would suggest you upgrade your selenium version to latest stable version 2.53.0 or >= 2.38.0 to get rid from this exception.
来源:https://stackoverflow.com/questions/39739025/errorthe-method-elementtobeclickableby-in-the-type-expectedconditions-is-not