Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error registering PhantomJS node in Selenium Grid

I have the following problem

  • I successfully launched Selenium Grid hub with:

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

  • After that I tried to launch PhantomJS node with:

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


but got Error:

[INFO - 2016-03-25T13:56:28.397Z] GhostDriver - Main - running on port 8090 [INFO - 2016-03-25T13:56:28.397Z] GhostDriver - Main - registering to Selenium HUB 'http://localhost:4444' version: using '127.0.0.1:8090' with org.openqa.grid.selenium.proxy.DefaultRemoteProxy as remote proxy. [ERROR - 2016-03-25T13:56:28.400Z] GhostDriver - main.fail - {"line":97,"sourceURL":"phantomjs://platform/hub_register.js","stack":"register@phantomjs://platform/hub_register.js:97:79\nglobal code@phantomjs://code/main.js:78:37"}

phantomjs://platform/console++.js:263 in error

Standard node works ok, but PhantomJS failes. What I'm doing wrong?

like image 801
uCodista Avatar asked Mar 25 '16 14:03

uCodista


4 Answers

For anyone still looking, there are linux and windows x64 builds available here with the workaround of v2.1.1 (windows build is on a pull request - the hex editor workaround wont work for windows cos the .exe's are compressed)

https://github.com/mrorgues/PhantomJSCustomEdition

like image 174
widowfactory Avatar answered Nov 13 '22 21:11

widowfactory


I have spent 2 months trying to fix this problem, trying everything possible, my main issue was that many solutions won't connect to the grid, and ones that do are in docker containers what can only connect to a local grid hosted on the same Docker host.

So... I finally built my own solution which works: https://github.com/madhavajay/selenium-node-phantomjs

Docker image is madhavajay/selenium-node-phantomjs

It uses PhantomJS 2.1.1 Custom Build with fixed Ghostdriver and then my own tweaks to the latest fork of Ghostdriver to allow a custom --remoteHost param all wrapped up in a Docker Container with configurable Environment Variables.

I hope this saves someone the lost weeks I suffered.

like image 45
Madhava Jay Avatar answered Nov 13 '22 21:11

Madhava Jay


workaround*** d/l source from phantomjs http://phantomjs.org/build.html and edit hub_register.js in the src/ghostdriver comment out lines as shown below:

//var ghostdriver = ghostdriver || {};

return {
    capabilities: [{
        browserName: "phantomjs",
        version: version,
        //platform: ghostdriver.system.os.name + '-' + ghostdriver.system.os.version + '-' + ghostdriver.system.os.architecture,
        maxInstances: 1,
        seleniumProtocol: "WebDriver"

compile and everything works!

shortcut: https://github.com/darwin10/phantomjs

Original Source : https://github.com/detro/ghostdriver/issues/394

like image 40
Ojen G. Avatar answered Nov 13 '22 21:11

Ojen G.


Try replacing localhost with local IP

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

with

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

like image 25
Ashmit Bhattarai Avatar answered Nov 13 '22 21:11

Ashmit Bhattarai