I tired to implement Phantomjs driver to Selenium tests but it throws me this error. java.lang.NoSuchMethodError: org.openqa.selenium.os.CommandLine.find(Ljava/lang/String;)Ljava/lang/String; The Phantom library is https://mvnrepository.com/artifact/org.jboss.arquillian.extension/arquillian-phantom-driver version 1.2.1.1 and Java version is 1.8 Implementation looks like:
if( driver == null )
{
if( which == CHROME )
{
System.setProperty("webdriver.chrome.driver", which);
driver = new ChromeDriver();
}
else if ( which == PHANTOM )
{
System.setProperty("webdriver.phantomjs.driver", which);
driver = new PhantomJSDriver();
}
}
What should I do to force it to work? Is it right Phantom library? Thanks.
For PhantomJSDriver (GhostDriver) you need to add the following Maven Dependency :
<dependency>
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.4.0</version>
</dependency>
Additionally, update the line System.setProperty
with the absolute path of the phantomjs
binary as follows :
File path=new File("C:\\path\\\to\phantomjs-x.x.x-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path",path.getAbsolutePath());
WebDriver driver= new PhantomJSDriver();
driver.navigate().to("https://www.google.co.in/");
Note: You can clean your project in IDE and use Selenium-Java Clients
dependency only.