1

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.

kittudk
  • 55
  • 3
  • 14

2 Answers2

2

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

szabgab
  • 6,202
  • 11
  • 50
  • 64
KeepCalmAndCarryOn
  • 8,817
  • 2
  • 32
  • 47
  • Thanks ! But am new to this concept of Phantomjs so can you be more specific. I just downloaded the zip from http://phantomjs.org/download.html. Now how to get started ? if any documentations are there kindly send me the link. – kittudk Jul 23 '13 at 11:19
  • updated with steps but just run phantomjs after you have started selenium – KeepCalmAndCarryOn Jul 23 '13 at 11:51
1

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();
Johnny
  • 14,397
  • 15
  • 77
  • 118