Currently Browsing

Posts Tagged ‘ Selenium Grid ’

How to connect multiple machines to the Selenium Grid hub

There might an instance in which we would want to run, for example, 50 tests in parallel.
50 browsers would consume the CPU power very fast, so we need to split the load between multiple machines.
Fortunately with Selenium Grid 2 this is not a problem.

How to register multiple browser types to Selenium Grid

If we want to register multiple types of browsers to Selenium Grid we must follow the following logic:
The base command for when we want to add a node to the hub is the following:
java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://localhost:5555/grid/register -browser browserName=firefox,maxInstances=5

How to run parallel tests with Selenium WebDriver and TestNG

First install Java JRE and JDK.
In Advanced system settings/ Environment Variables setup java path:
Create a new system variable (if it is not created):

Name: JAVA_HOME
Value(the location of the jdk):   C:\Program Files\Java\jdk1.7.0_25

In to the Path variable add:
The location of jre:  c:\Program Files (x86)\Java\jre7\bin\;

Install selenium and testing to Eclipse.
Download (from  code.google.com) the selenium-server-standalone-2.33.0.jar file (or the newest).
Copy this file to a simple place, for example C:\

Now open command prompt (with administrator privileges).
Go to c:\ and enter the following line to start Selenium Grid:
java -jar selenium-server-standalone-2.33.0.jar -role hub -port 4444

Open a new command prompt window, go to c:\ and enter the following line to register the browser to the Selenium Grid:
java -jar selenium-server-standalone-2.33.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=firefox,maxInstances=3

The maxInstance will determine the max number of the browsers. If it is set to 3 than maximum 3 browsers(tests) are able to run parallel.
(If you want to know more about Selenium Grid visit the Selenium site: http://docs.seleniumhq.org/docs/07_selenium_grid.jsp )

Now in Eclipse create a new project, a new package and a new class. Name it TestBase.
To this file create:
•    a new RemoteWebDriver,
•    to the @BeforeMethod the setUp() function
•    to the @AfterMethod the tearDown() function
•    getDriver() function