I run the selenium-selenium hub with its default start command,
java -jar selenium-server-standalone-2.33.0.jar -role hub
And I run PhantomJS in this webdriver mode, on the same computer, for example,
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
When PhantomJS starts up, I get only "All" OK messages,
[INFO - 2013-09-09T18:10:38.849Z] GhostDriver - Main - running on port 8080 [INFO - 2013-09-09T18:10:38.850Z] GhostDriver - Main - registering to Selenium HUB 'http://127.0.0.1:4444' using '127.0.0.1:8080' [INFO - 2013-09-09T18:11:47.164Z] HUB Register - register - Registered with grid hub: http://127.0.0.1:4444/ (ok)
But if I try to use this browser,
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities.PHANTOMJS)
Looking at the output from the PhantomJS executable,
[INFO - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - _decorateNewWindow - page.settings: {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.2 Safari/534.34","webSecurityEnabled":true} [INFO - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - page.customHeaders: - {} [INFO - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - CONSTRUCTOR - Desired Capabilities: {"platform":"ANY","javascriptEnabled":true,"browserName":"phantomjs","version":""} [INFO - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":"mac-10.7 (Lion)-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}} [INFO - 2013-09-09T18:17:12.531Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 0c5c9500-197c-11e3-8eed-b3b7a73965aa
Everything seems to be fine, but the code crashes: / I get a huge stacktrace error, mostly until
selenium.common.exceptions.WebDriverException: Message: u'Error forwarding the new session new session request for webdriver should contain a location header with the session.'
And if you check the output of the grid hub,
INFO: Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=phantomjs, maxInstances=1} INFO: Available nodes: [host :http://127.0.0.1:8080 time out : 300000]
There also seems to be a problem. For some reason, the network hub does not get any information from the PhantomJS executable, although it seems that it handles things correctly.
For testing, I also have a regular selenium node, running on the same computer, with the command
java -jar selenium-server-standalone-2.33.0.jar -role node
and if I started a remote access session to a remote Firefox server (in Python),
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX)
everything is good.
Everything seems to be set up correctly, I keep things like 'vanilla' and as close to what the docs say as possible, but just can't get over this fence.
Exactly the same error occurs when you try Java.
WebDriver driver = new RemoteWebDriver(DesiredCapabilities.phantomjs());
A screenshot of the console with the connection, PhantomJS is alive and well there,

The default left is the selenium node, the right is PhantomJS (and 10.0.0.222 is my laptop's IP address at work).
And my versions are 1.9.2 for PhantomJS and obviously 2.33.0 for selenium.