Ans- use @Parameters to pass the input through xml.
Ex-
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class PassInputThruXML {
@Test
@Parameters({"para1","para2"})
public void passInput(String para1, double para2){
System.out.println(para1);
System.out.println(para2);
}
}
testng.xml->
<suite name="Suite" parallel="none">
<test name="Test">
<parameter name="para1" value="selenium-makeiteasy" />
<parameter name="para2" value="5.0" />
<classes>
<class name="TestNg.PassInputThruXML"/>
</classes>
</test>
</suite>
Ex-
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class PassInputThruXML {
@Test
@Parameters({"para1","para2"})
public void passInput(String para1, double para2){
System.out.println(para1);
System.out.println(para2);
}
}
testng.xml->
<suite name="Suite" parallel="none">
<test name="Test">
<parameter name="para1" value="selenium-makeiteasy" />
<parameter name="para2" value="5.0" />
<classes>
<class name="TestNg.PassInputThruXML"/>
</classes>
</test>
</suite>
No comments:
Post a Comment