Is there any way to use Parameters with DataProvider
together in Selenium ?
@Parameters({"safaf"})
@DataProvider(name="sss")
public void hhhhh (String safaf){
}
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityYes, it can be done. Parameter passing in TestNG can be done two ways:
@Parameter
tag and you pass the value from your testng.xml
Useful when your dealing with simple parameter@DataProvider
tag
Useful if your reading values from prop file or database.So your testng.xml will look something of this sort:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite123">
<test name="test123">
<parameter name="safaf" value="blah"/>
<classes>
<class name="DataProvider123" />
</classes>
</test>
</suite>
DataProvider is a method in a class that returns a two dimensional an array of object (Object [ ][ ]) to the test method. The test method will be called m times in the m*n type of object array. Where m ➨ The first array m represents the number of rows that has to be repeated your test m number of times. n ➨ The second array n represents a column that is the number of parameters in the test data. This method is annotated with @DataProvider. DataProvider in TestNG