My Blog List

Monday, September 26, 2011

Selenium Grid with TestNG


Hi all,
Here I want to share some information on "How to run selenium tests in parallel using Grid".

Steps:

1.     Keep ready the tests and TestNG.xml file by including tests to be run.
2.     Launch the Grid using "ant launch-hub"
3.     Then, launch how many RC instances you want to run on different environments like,  "ant launch-remote-control"
1.     You should use parameter -DhubURL=yourHubURL. Here yourHubURL is the machine address in which you launched Grid Hub.
2.     then you can use parameters -Dport, -Denvironment, -Dhost to launch different RCs.
4.     So now, Hub and RC instances are running. To see the running instances, goto http://localhost:4444/console
5.     After this, you have to make test multiplication for the purpose of making each instance to run a test.Because all instances will not share a single test.
So make the testng.xml file as below. I have a test

<suite name="Suite1"  parallel="tests" thread-count="2">
<test name="TestPlans1" preserve-order="false" > 
<parameter name="Browser" value="*firefox">
    <classes> 
      <class name="TestPlans.TestPlan_1"> 
        <methods> 
        </methods> 
      </class> 
      <class name="TestPlans.TestPlan_2"> 
        <methods> 
          <include name="TestCase_1"/> 
          <include name="TestCase_2"/>
        </methods> 
      </class> 
    </classes> 
  </test> 

This is my actual XML file. But I created this copy with another test name inside only my browser is changed. So it will run separately on different specified browsers.

<test name="TestPlans2" preserve-order="false" > 
<parameter name="Browser" value="*iehta">
    <classes> 
      <class name="TestPlans.TestPlan_1"> 
        <methods>
        </methods> 
      </class> 
      <class name="TestPlans.TestPlan_2"> 
        <methods> 
          <include name="TestCase_1"/> 
          <include name="TestCase_2"/>
        </methods> 
      </class> 
    </classes> 
  </test> 

6. Now go and Run the TestNG test from Eclipse. Thats all.


Also you can refer for details here. SeleniumGrid

1 comment:

  1. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete