Friday 22 July 2016

How to execute scripts in parallel in selenium

How to execute scripts in parallel in selenium:
===================================
By using testing.xml we can execute the test cases parallel

TestOne.java:
=============
package com.rs.blog;

import org.testng.annotations.Test;

public class TestOne {

       @Test
       public void scriptOne() {
              System.out.println("script one");

       }

}

TestTwo.java:
===============
package com.rs.blog;

import org.testng.annotations.Test;

public class TestTwo {

       @Test
       public void scriptOne() {
              System.out.println("script one");

       }

}

Testing.xml:
=============
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" thread-count="3" parallel="methods" >
  <test name="Test">
    <classes>
      <class name="com.rs.blog.TestTwo"/>
      <class name="com.rs.blog.TestOne"/>
    </classes>
  </test> <!-- Test -->

</suite> <!-- Suite -->

Thread-count:  If the thread count is 3 so 3 web driver instances can run parallel in 3 different browsers
Parallel:
=======
The parallel attribute of suite tag can take three values:
1                              Tests: All the test cases inside <test> tag of testing xml file will run parallel
2                             Classes: All the test cases inside a java class will run parallel
3                              Methods: All the methods with @Test annotation will execute parallel










No comments:

Post a Comment