If i need to run same one method with two different browser at the same time then how will i implement it? For example:
public class AppTest2{
@parameters("browser")
@Test(dataProvider="loginData")
public void login(String userName , String password, String param){
if(param.equals("firefox"){
//do something
}
if(param.equals("chrome"){
//do something else
}
}
}
in my testng.xml file contains:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name ="My sutie" parallel = "methods", thread-count="5">
<parameter name="browser" value="firefox"/>
<test name ="My Test1">
<classes>
<class name="mq.demo.selenium.AppTest2"/>
</classes>
</test>
</suite>
So my target is to run the login method in two different browser at the same time using two different thread.
Can anyone Help?
Thanks
You can consider something like the below as a possible solution
The suite xml file can look like below
So as you can see, here we are resorting to using a TestNG listener called
IAlterSuiteListener
implementation which is going to help us construct the<test>
tags in the suite xml file dynamically and the number of<test>
tags in the suite xml file will be directly equal to the number of browsers specified either via the suite level parameterbrowserFlavors
(or) via the JVM argument-DbrowserFlavors
The output would be as below