Error:The method elementToBeClickable(By) in the type ExpectedConditions is not applicable for the arguments (WebElement)

允我心安 提交于 2019-12-25 09:15:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!