Google Analytics

Search

To search for specific articles you can use advanced Google features. Go to www.google.com and enter "site:darrellgrainger.blogspot.com" before your search terms, e.g.

site:darrellgrainger.blogspot.com CSS selectors

will search for "CSS selectors" but only on my site.


Friday, March 9, 2012

Help for selenium-server-standalone.jar

 
One thing you might not realize if you have been trying to get command line help from the Selenium Server jar file is that there are two different help outputs.

If you run the server with no inputs it just runs with no help at all.

As an old UNIX/Linux guy I have gotten used to the standard of a single dash and a single letter (e.g. -h for help) or two dashes and a word (e.g. --help) I was a little thrown by the Selenium Server jar file.

The reason is that -h will give you help for the Standalone Selenium Server but --help will launch the Standalone Selenium Server. The Grid Selenium Server is in there but getting help for it is not obvious.

The help switch for Grid Selenium Server is actually -help (not the same as -h but not quite the Linux convention). Actually, this will give you the help message for the Standalone Server and the Grid Server.

For running the Grid, you need to specify hub or node. If you want to run it as a hub you would use:
java -jar selenium-server-standalone.jar -role hub
Looking at the rest of the help you will see some switches have (hub), some have (node) and some have (hub & node). If the switch has a (hub) then that switch applies only when using -role hub. Conversely, if it has (node) then it only applies to -role node.

Generally, you will set up one hub and multiple nodes. For example, the application I am currently testing needs to be tested on:

  • Windows 7 with IE9
  • Windows XP with IE6
  • Mac OS X 10.8 with Safari 10
So I would run Grid Selenium Server with (omit the text after the # symbol):
  • -role hub # (defaults to localhost and 4444)
  • -role node -hubHost hubmachine -hubPort 4444 -browser browserName=iexplore,version=9,platform=VISTA # (Windows 7, IE9)
  • -role node -hubHost  hubmachine -hubPort 4444 -browser browserName=iexplore,version=6,platform=XP # (Windows XP, IE6)
  • -role node -hubHost  hubmachine -hubPort 4444 -browser browserName=safariproxy,version=10,platform=MAC # (Mac OS X, Safari 10)
The -hubHost and -hubPort just need to match the host and port for the hub. If you specify a -port for the hub then you need to change the settings for the nodes as well. In this example, I have the hub running on the computer with name hubmachine.

The -browser option is a little tricker. It mirrors the Selenium code. 

If you look at the Selenium Client source code for src/org/openqa/selenium/remote/BrowserType.java you will find a list of the strings which can be used with the browserName key. At this time for following values are permitted:
  • firefox
  • firefoxproxy
  • safari
  • opera
  • iexplore
  • iexploreproxy
  • safariproxy
  • chrome
  • mock
  • iehta
The platform key comes from src/org/openqa/selenium/Platform.java and valid values at this time are:
  • WINDOWS
  • XP
  • VISTA
  • MAC
  • UNIX
  • LINUX
  • ANDROID
  • ANY
When you look at the Platform.java file you will see that Windows 7 'feels like' Windows Vista. So we use the VISTA platform when we want Windows 7.

At this point, if you go to http://localhost:4444/ you'll have a link to the Grid2 Wiki and a link to the console. If you go to the console you should see an entry for each of the nodes you are running. All the nodes will be running on port 5555 but different machines.

You can also go to the Grid2 Wiki from the hub home page. You might want to take the time to have a look at that as well. There are additional parameters for the node. For example, I can add maxInstances=3 to the browser string and it will let me run up to 3 instances of that browser on the computer. By default the maxInstances will be 5.