Selenium RC environments with whitespace characters

We use selenium grid to orchestrate our acceptance testing over multiple browsers on multiple platforms. One of the nice things with registering environments with the selenium grid hub, is that you can use descriptive names like: “IE on Windows XP” and “Firefox on OS X” for example.

I was having difficulties with environment names with whitespace characters, so after a lot of experimentation, here are the tweaks I made to get it working across all Linux and Windows.

The Rakefile for the selenium-grid needs to have the rc_args method redefined as follows (notice the changes on lines 6 and 7):


def rc_args(options)
  args = []
  args << "-host" << (options[:host] || ENV['HOST'] || "localhost&quot ;)
  args << "-port" << options[:port]
  args << "-hubUrl" << (options[:hub_url] || ENV['HUB_URL'] || 'http://localhost:4444' ;)
  args << "-env" << "\"#{(options[:environment] || ENV['ENVIRONMENT'] || "*chrome")}\""
  args << "-env" << "\"#{(options[:environment] || ENV['ENVIRONMENT'] || "*chrome")}\""
  args << (options[:selenium_args] || ENV['SELENIUM_ARGS'] || "&quot ;)
  args
end

Now you can run the RCs from the command line as follows:

On windows:

rake rc:start PORT=5555 HUB_URL=http://172.16.7.122:4444 HOST=172.16.7.119 ENVIRONMENT=”IE on Windows Vista”

On linux:

rake rc:start PORT=5555 HUB_URL=http://172.16.7.122:4444 HOST=172.16.7.119 ENVIRONMENT=Safari\ on\ OS\ X

 

Posted in Selenium.

Leave a Reply