Multiple Browser Parallel Execution:
SuitePortalMultipleBrowser.xml
<?xml version="1.0"
encoding="UTF-8"?>
<suite name="Parallel_Execution"
parallel="tests" thread-count="2"
verbose="10">
<listeners>
<listener
class-name="org.imaginea.jenkins.plugins.testinprogress.testng.TestNGProgressRunListener" />
</listeners>
<test name='Test1'>
<classes>
<class name='com.net.OfficersPortalTest'
/>
</classes>
</test>
<test name='Test2'>
<classes>
<class name='com.net.DisplaySettingsPortalTest'
/>
</classes>
</test>
<test name='Test3'>
<classes>
<class name='com.net.MessagePortalTest'
/>
</classes>
</test>
<test name='Test4'>
<classes>
<class name='com.net.FamilynFriendsPortalTest'
/>
</classes>
</test>
</suite>
Here,
·
parallel = “tests” à It helps to parallel run of
test classes.
·
thread-count = “2” à 2 is number of browser
which are executed parallelly. Here we can use 3, 4 or so on.
·
Verbose =”10” à Verbose Attribute lets you obtain clear
reports through IDE console. This attribute will be placed inside the
<Suite> tag of testng.xml as shown below:
<suite name="Parallel_Execution"
parallel="tests" thread-count="2"
verbose="10">
Some
conditions also needed to perform parallel browser execution for elementary
level.
Condition
- 1: RemoteWebDriver will not be static.
/**
* driver for the browser
*/
public
RemoteWebDriver driverBrowser;
Condition
- 2: If we want to quit the browser after processing every test class, we need
to add the method in every test class.
/**
* Called by TestNG after each Test is called.
*
* @throws Exception
*/
@AfterTest(alwaysRun = true)
public void testCleanUp() throws Exception {
if (driverBrowser != null) {
driverBrowser.quit();
}
}
No comments:
Post a Comment