Error: java.lang.NoClassDefFoundError: org / openqa / selenium / HasInputDevices when running tests using ghostdriver

I am trying to run my test cases for webdriver using ghostdriver (Phantomjs), but this gives the error java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices .
Everything seems good to me, but I don’t understand why there is a mistake.
OS - WIN7
Coding - JAVA 1.7
Frame: 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> 
+4
source share
1 answer

Your problem is that ghostdriver is not compatible with Selenium 2.35 .

If you change your dependency to 2.34, everything will be fine. Unfortunately, you will have to wait for the new PhantomJSDriver if you especially need Selenium 2.35.

Currently, the latest version of phantomjsdriver is 1.0.4, and 1.0.3.

+8
source

Source: https://habr.com/ru/post/1502385/


All Articles