2012-10-26 117 views
0

在常规使用的webdriver 2.25.0使用此代码神秘MissingMethodException:对webdriver的cssSelector方法

import org.openqa.selenium.By; 
... 
driver.findElement(By.cssSelector("div.test")) 

表演:

groovy.lang.MissingMethodException: No signature of method: static org.openqa.selenium.By.cssSelector() is applicable for argument types: (java.lang.String) values: 

docs状态这种方法是有效的。我无法弄清楚这个方法如何解决,而“name()”是。

+0

您确定您在类路径上有正确的WebDriver版本吗?什么'By.methods.findAll {it.name ==“cssSelector”}'打印? –

回答

0

终于明白了这一点。我使用的是HtmlUnitDriver,其中apparently不是implement By.cssSelector。您可以想象我的惊喜,因为看似最新的文档indicate otherwise

我可以使用com.gargoylesoftware.htmlunit.html.DomNode上的“querySelector”方法跟踪替换功能,但我还没有弄清楚com.gargoylesoftware.htmlunit和org.openqa之间的关系。 selenium.html单元。

相关问题