pau*_*aul 4 webdriver maven-3 phantomjs
我试图使用ghostdriver(Phantomjs)运行我的webdriver测试用例但是这给出了错误java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices.
一切似乎都很好,但我不明白为什么会有错误.
OS - WIN7
编码 - JAVA 1.7
框架:java1.7 + testng6.5.2 + maven3
Selenium-java版本2.35.0
测试用例
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
public class ghosttest {
WebDriver driver;
@Test
public void testing() {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"D:/dumps/phantomjs-1.9.1-windows/phantomjs-1.9.1-windows/phantomjs.exe");
driver = new PhantomJSDriver(caps);
driver.get("http://www.google.com");
String Logintext = driver.findElement(By.linkText("Maps")).getText();
System.out.println(Logintext);
}
}
Run Code Online (Sandbox Code Playgroud)
ghostdriver的maven依赖
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.0.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
你的问题是ghostdriver 与Selenium 2.35不兼容.
如果你将你的依赖关系改为2.34你会没事的.如果你特别需要Selenium 2.35,你将不得不等待新的PhantomJSDriver.
目前最新版本的phantomjsdriver也是1.0.4,你有1.0.3.
| 归档时间: |
|
| 查看次数: |
11210 次 |
| 最近记录: |