Monday, June 18, 2012

Using Grid2 to run tests on multiple machines/browsers

Grid allows you to :

  • Scale by distributing tests on several machines (parallel execution)
  • Manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS.
  • Minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance.

Setup:

  • Download the latest selenium-server-standalone-*.jar from http://code.google.com/p/selenium/downloads/list.
  • Start the Hub - open CMD and run: 
    • java -jar selenium-server-standalone-*.jar -role hub
  • Start the nodes - open CMD and run:
    • java -jar selenium-server-standalone-*.jar -role node  -hub http://localhost:4444/grid/register
It is easier to create *.bat files to run the server. Also bat files can be scheduled to run on desired time on remote machines. Just create a *.txt file and rename it to *.bat:

cd c:\selenium-server (location of your server)
java -jar selenium-server-standalone-*.jar -role hub

Using Grid2 in tests:


DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName("firefox");
driver = new RemoteWebDriver(
    new URL("http://<IP of your remote machine>:4444/wd/hub"),
capability);

More info: http://code.google.com/p/selenium/wiki/Grid2

No comments:

Post a Comment