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>
source share