How can I execute multiple test class 'test1'
and 'test2'
parallely? Which is using the same function in another class using TestNG.
When I define the parallel option as 'classes' and thread-count as '2' in TestNG XML, the login page is loading two times, but 'sendelement' method is executing in single browser two times simultaneously.
for eg; if my login is 'user1'
, sendelement
function execute two times as 'user1user1'
in the username field and shows invalid login.
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> -->
<suite name="Suite" parallel="classes" thread-count="2">
<test name="NavigationTest">
<classes>
<class name="Test1" />
<class name="Test2" />
</classes>
</test>
</suite>
public class Test1 {
loginToUserPage(strUserName, strPassword);
}
public class Test2{
loginToUserPage(strUserName, strPassword);
}
public class Test3
{
public void loginToUserPage(String strUserName,String strPassword)
{
webdriverCommon.windowMaximise();
webdriverCommon.sendElement(CommonRepo.userName_Edit, strUserName);
webdriverCommon.sendElement(CommonRepo.password_Edit, strPassword);
webdriverCommon.clickElement(CommonRepo.logginButton_buttton);
}
}