Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
How do you pass value to test method method? from your data provider

Solved 1 Answers 144 Views Programming
0 1

I am not sure how to pass username ,password values to my test method from my data provider. My @DataProvider looks something similar to this,

@DataProvider(name="dataprovider")

public Object [][] getData()

{

Object[][] data = new Object[1][2];

Hashtable<String, String> credential1 = new Hashtable<String, String>();

credential1.put("username", "admin");

credential1.put("password", "admin");

Hashtable<String, String> credential2 = new Hashtable<String, String>();

credential2.put("username", "admin");

credential2.put("password", "WCM2k8Ap");

data[0][0] = credential1;

data[0][1] = credential2;

return data;

}

 

 

1 Answer

0
Best answer
0

You can receive it like below.

@Test(dataProvider="dataProvider")
public void myTest(Hashtable<String,String> credential1,Hashtable<String,String> credential2){
String username1 = credential1.get("username");
String username2 = credential2.get("username");
}

 

answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...