我想用Selenium Java實例化一個PhantomJS驅動程序。下面是代碼:Selenium - Java:PhantomJS:引起:java.lang.ClassNotFoundException:org.openqa.selenium.remote.HttpVerb
File file = new File("C:\\Softwares\\drivers\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
driver.get("http://www.google.com");
我與不同版本的硒的嘗試和我收到了同樣的異常:
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.HttpVerb
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/HttpVerb
at org.openqa.selenium.phantomjs.PhantomJSDriver.getCustomCommands(PhantomJSDriver.java:166)
at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.<init>(PhantomJSCommandExecutor.java:62)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
我用我的項目依賴的文章:
- phantomjsdriver
- 硒 - common.jar
- 硒-java的2.5 3.1。 jar
我使用過期版本的硒庫的原因是由於我在互聯網上發現的一些文章說遠程/ HttpVerb已被棄用,降級庫會刪除錯誤。不過,我仍然得到這個錯誤
是烏爾問題就迎刃而解了? – iamsankalp89