getting selenium, ghostdriver, phantomJS working o

2019-05-21 08:20发布

问题:

I am using selenium-2.34 and phantomJS-1.9.1-windows

however when i try to use:

import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;

I can see that it does not detect

org.openqa.selenium.phantomjs

getting this error

The import org.openqa.selenium.phantomjs cannot be resolved

I was under the impression that GhostDriver was embedded in PhantomJS - https://github.com/detro/ghostdriver

does anyone know what could be wrong with my setup?

EDIT: Could this be due to a path issue, do i need to supply some way for selenium to pick up these up https://github.com/detro/ghostdriver/tree/master/binding/java/src/main/java/org/openqa/selenium/phantomjs

回答1:

Just add following in your pom.xml (if maven used):

<dependency>
    <groupId>com.github.detro.ghostdriver</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.0.3</version>
</dependency>

Or, if maven not used, grab JAR file from here: http://grepcode.com/snapshot/repo1.maven.org/maven2/com.github.detro.ghostdriver/phantomjsdriver/1.0.3/