Question

Can anyone suggest me good documentations or steps to start or configure phantomJs driver in java so that i can run my test cases in remote server.

Was it helpful?

Solution

I run the selenium server in grid mode then connect the phantomjs to it after it is up as it doesn't try to reconnect if it disconnects or isn't fully up

./phantomjs --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444

which will have it listen on port 5558 (for example) but you connect through selenium an it appears as browser phantomjs on Any platform

Steps

java -jar selenium-server-standalone-2.14.0.jar -role hub 

./phantomjs --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444

You can then run tests as per the selenium web site https://code.google.com/p/selenium/wiki/Grid2

I use perl to run tests http://metacpan.org/pod/Selenium::Remote::Driver but there are many choices

OTHER TIPS

First of all, add the relevant dependency of phantomJsDriver (GhostDriver) to the POM file:

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

You can find the full guide here

Then, work with it like with ordinary WebDriver as described in Selenium manuals, but, instead of initialising HtmlUnitDriver:

WebDriver driver = new HtmlUnitDriver();

Initialize PhantomsJsDriver:

WebDriver driver = new PhantomJsDriver();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top