Selenium
WebDriver Training
Parametrization
The Golden Circle
What
What is Dyanmic parameterization?
To pass external test data to the testcases.
Why Why do we need to use it?
To test the same functionality with different set of data or for running the same
test with different configurations.`
How to do parametrization?
How
Using TestNg annotation based on the type of data
Dynamic Parameterization:
Supports multiple set of data to pass into single functionality
Can be achieved by using @DataProvider annotation on top of the
method supplying data to testcase.
@DataProvider
public object[][] sendData(){
object[][] data= object[2][2] ;
data[0][0] =01;
data[0][1]=“Emp1”;
data[1][0] =02;
data[1][1]=“Emp2”
}
Steps to achieve dynamic parametrization
Step:1 Create a normal method with return type of String[][]
Step:2 Declare and assign the value to the 2D Dimensional array
Step:3 Add @DataProvider annotation on top of the method
Step:4 Add dataProvider attribute the @Test Method
Step:5 Add arguments to @test method to pass data from the DataProvider Method
Steps to achieve dynamic parametrization
@DataProvider(name="getData")
public String[][] fetchData() {
*Here the 2 set of data is passed to the create lead String[][] data=new String[2][4];
functionality data[0][0]="TestLeaf";
data[0][1]="Hari";
*Each data to dataprovider is considered to be a data[0][2]="R";
individual testcase data[0][3]="99";
data[1][0]="TestLeaf";
data[1][1]="Babu";
data[1][2]= "Manickam";
data[1][3]="91";
return data; }
public class CreateLead extends BaseClass{
@Test(dataProvider = "getData")
public void createLead(String companyname,String firstname,String lastName,String phonenum)
{[Link]([Link]("createLeadForm_companyName")).sendKeys(companyname);
[Link]([Link]("createLeadForm_firstName")).sendKeys(firstname);
[Link]([Link]("createLeadForm_lastName")).sendKeys(lastName);
[Link]([Link]("createLeadForm_primaryPhoneNumber")).sendKeys(phonenum);
[Link]([Link]("submitButton")).click();
Summary
Dynamic Parametrization- to supply multiple set of data
Data supplied throughtestcase
Using @DataProvider and dataProvider attribute of @Test