当使用“new FirefoxDriver()”时,我总是得到一个“NoSuchMethodError:org.apache.xpath.XPathContext”

时间:2013-12-06 12:27:09

标签: selenium xpath selenium-webdriver nosuchmethoderror selenium-firefoxdriver

使用new FirefoxDriver()时,我总是得到一个

  

NoSuchMethodError:org.apache.xpath.XPathContext

     

(线程“main”java.lang.NoSuchMethodError中的异常:   org.apache.xpath.XPathContext。(Z)V at   org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:115)     在   org.apache.xpath.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:99)     在   org.apache.xpath.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:184)     在   org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:120)     在   org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:60)     在   org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:63)     在   org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:464)     在   org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:442)     在   org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:79)     在   org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:250)     在   org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:110)     在   org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:195)     在   org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:190)     在   org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:107)     在test.PerfTest.main(PerfTest.java:35))

1 个答案:

答案 0 :(得分:3)

可能xalan.jar造成这种情况。检查类路径中是否有不同版本的xalan,并尝试检查webdriver是否引用了正确的jar。你可以尝试

System.out.println(new XPathContext().getClass().getProtectionDomain().getCodeSource().getLocation());

检查它正在使用哪个罐子。