I am trying to run my webdriver test cases using ghostdriver (Phantomjs) but that's giving error java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices
.
Everything seems fine to me but I dont understand why there is error.
OS - WIN7
Coding - JAVA 1.7
Framework : java1.7+testng6.5.2+maven3
Selenium-java version 2.35.0
testcase
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);
}
}
maven dependency for ghostdriver
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.0.3</version>
</dependency>
Your problem is that ghostdriver is not compatible with Selenium 2.35.
If you change your dependency to 2.34 you will be fine. You will have to wait for a new PhantomJSDriver unfortunately if you specifically need Selenium 2.35.
Currently the latest version of phantomjsdriver is 1.0.4 as well, you had 1.0.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With