Copy paste the line below to your terminal:
https://gist.githubusercontent.com/neuro-sys/3bf00b6cf28a93e07e44/raw/e8976da93a55e5ef7c5e8dc99c00772fffb06f6c/replacestring.c
gcc replacestring.c -oreplacestring
./replacestring "$(strings /usr/bin/phantomjs | grep "platform: ghostdriver")" " " < /usr/bin/phantomjs > phantomjs && chmod a+x phantomjs
sudo cp phantomjs /usr/bin/phantomjs
Alright, there's a bug in a recent version of PhantomJS which renders it unable to run with GhostDriver. The error is like this:
[neuro@localhost]$ phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
[INFO - 2015-06-09T16:09:46.432Z] GhostDriver - Main - running on port 8080
[INFO - 2015-06-09T16:09:46.433Z] 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-06-09T16:09:46.437Z] GhostDriver - main.fail - {"line":96,"sourceURL":"","stack":"\tat \n\tat global code (:/ghostdriver/main.js:78:37)"}
:262 in error
[neuro@localhost]$
There're several bug reports in the github bug tracker of the said project, and in one of them some nice gentleman points at how to fix the problem. (https://github.com/detro/ghostdriver/issues/394#issuecomment-75531714)
However this requires building the upstream yourself, which in my case takes forever to do so due to a large dependency chain (I've seen QT among them, god knows why).
Here's a quick and dirty way to fix the issue until your distribution updates the package.
- 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,
-
Run and profit.
[neuro@localhost ]$ 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 'http://127.0.0.1:4444' 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: http://127.0.0.1:4444/ (ok)
- You may as well get this tiny program to replace a string in a binary, because using sed might corrupt the file. https://gist.github.com/neuro-sys/3bf00b6cf28a93e07e44
- Or just copy paste the following into your terminal:
wget https://gist.githubusercontent.com/neuro-sys/3bf00b6cf28a93e07e44/raw/e8976da93a55e5ef7c5e8dc99c00772fffb06f6c/replacestring.c
gcc replacestring.c -oreplacestring
./replacestring "$(strings /usr/bin/phantomjs | grep "platform: ghostdriver")" " " < /usr/bin/phantomjs > phantomjs && chmod a+x phantomjs
sudo cp phantomjs /usr/bin/phantomjs
Nice but you need to do
sudo dhex /usr/local/bin/phantomjs
if you have installed with brew on a mac and you can also get dhex from brew