Running WebdriverJS test on Selenium Grid

I have a Selenium Grid running on AmazonEC2

It consists of a hub running on port 7055 and a node running on port 7056.

I have the following test:

var webdriver = require('selenium-webdriver'),
    driver = new webdriver.Builder().
       usingServer('http://ec2-50-18-75-182.us-west-1.compute.amazonaws.com:7055/wd/hub').
       withCapabilities({'browserName': 'firefox'}).
       build();


var postTitle = "Post "+(+new Date);

driver.get('http://si-demo.herokuapp.com/posts/new');
driver.findElement(webdriver.By.id('post_name')).sendKeys("Selenium");
driver.findElement(webdriver.By.id('post_title')).sendKeys(postTitle);
driver.findElement(webdriver.By.id('post_content')).sendKeys("This is auto generated by a test");
driver.findElement(webdriver.By.name('commit')).click();
driver.quit();

That fails when I try to connect to the hub port. The test does run when I connect directly to the node port.

The error I get when connecting to the grid hub is:

timers.js:103
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
Error: ETIMEDOUT connect ETIMEDOUT
    at ClientRequest.sendRequest (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/http/index.js:127:16)
    at ClientRequest.EventEmitter.emit (events.js:96:17)
    at Socket.socketErrorListener (http.js:1436:9)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
==== async task ====
WebDriver.createSession()
    at Function.webdriver.WebDriver.acquireSession_ (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:130:49)
    at Function.webdriver.WebDriver.createSession (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:109:30)
    at Builder.build (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/builder.js:70:22)
    at Object.<anonymous> (/Users/jason/Development/cirrus/spanish-inquisition-runner/open_canvas.js:5:8)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)

My question is: Does Selenium WebdriverJS support connecting to the hub? If so what am I doing wrong?

Notes:

  • I have connected to the hub and successfully run the same steps as an rspec test.
  • I was also able to connect to the hub locally on the EC2 instance and run the test, only happens when trying to connect remotely to the grid.
  • When looking at the Selenium2 grid console at :7055/grid/console it does appear to be using a session on the node.

Commands I used on EC2 to start the grid:

Xvfb :0 -screen 0 1024x768x24 2>&1 >/dev/null &
export DISPLAY=:0
java -jar selenium-server-standalone-2.32.0.jar -port 7055 -role hub
xvfb-run java -jar selenium-server-standalone-2.32.0.jar -role node -hub http://localhost:7055/grid/register

Have you tried using remote webdriver? I haven't usethe JS driver, but C# has a specific driver for remote grid connections.

https://code.google.com/p/selenium/wiki/WebDriverJs#Using_the_Stand-alone_Selenium_Server

Looking at the JS docs, you probably need to do something like this when you construct your driver:

var webdriver = require('selenium-webdriver'), 
    SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;