power_settings_new

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

by
asked
0 like 0 dislike
162 views
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;

}

 

 

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.

1 Answer

answered by
selected by
0 like 0 dislike
 
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");
}

 

Related questions

add
...