4

I'd like to replace Firefox with PhantomJS for our PHPUnit-run Selenium tests. However, I haven't got a clue how to start. When we're using Firefox, something like this is in our code:

$this->setBrowser("firefox");
$this->setFirefoxBinary("/path/to/firefox");

However, Phantom should probably be started as another service and when I run this command as suggested on the Ghostdriver homepage:

 phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444

It just fails with

[INFO  - 2015-03-06T14:55:02.431Z] GhostDriver - Main - running on port 8080
[INFO  - 2015-03-06T14:55:02.438Z] GhostDriver - Main - registering to Selenium HUB 'http://127.0.0.1:4444' version:  using '127.0.0.1:8080' with org.openqa.grid.selenium.proxy.DefaultRemoteProxy as remote proxy.
[ERROR - 2015-03-06T14:55:02.462Z] GhostDriver - main.fail - {"line":96,"sourceURL":"","stack":"\tat \n\tat global code (:/ghostdriver/main.js:78:37)"}

  :262 in error

I haven't been able to find any tutorials or anything for the new version 2.0, has anyone got it working?

3

Or there's a third alternative to what Vangelisz suggested.

Here's a dirty & quick way to fix the issue.

  • Fire up your favorite hex editor and edit/view the phantomjs executable:

    $ dhex /usr/bin/phantomjs

  • For ghostdriver is written in javascript and embedded in the phantomjs distribution as plain-text, look for the line that's causing the bug:

  • Remove the line by filling up it with 0x20 (space) values. The line that you need to find and fill with ascii space characters is this: platform: ghostdriver.system.os.name + '-' + ghostdriver.system.os.version + '-' + ghostdriver.system.os.architecture,

  • And then run as usual.

    $ phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444

    [INFO - 2015-06-09T16:30:16.636Z] GhostDriver - Main - running on port 8080 [INFO - 2015-06-09T16:30:16.636Z] GhostDriver - Main - registering to Selenium HUB '' version: using '127.0.0.1:8080' with org.openqa.grid.selenium.proxy.DefaultRemoteProxy as remote proxy. [INFO - 2015-06-09T16:30:16.689Z] HUB Register - register - Registered with grid hub: (ok)

Follow up: https://gist.github.com/neuro-sys/41e368839a9b20dafb34

2

This was a bug in the latest version: https://github.com/detro/ghostdriver/issues/394

Either you build your own executable with the hint provided, or wait for the fix (or use an earlier build).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.