Returning data from multiple data provider | Selenium Forum
M
Posted on 27/07/2016
The hashtable that is returned from the Data Provider is for the "CreateLeadTest" but the user name and password is mentioned under "loginTest". Do I have to mention username and password for each and every test case? If not then how do I return username and password from the data provider?

//login function passing username and password from excel
doLogin(data.get("Username"), data.get("Password"));

@DataProvider
public Object[][] getData()
{
super.init();// initializing the property file
xls = new ReadExcel(prop.getProperty("xlspath"));
return Utility.getData(CreateLeadTest, xls); // reading from "CreateLeadTest"
}

//Data Sheet:

loginTest // username and password is listed here
Runmode Browser Username Password
y Mozilla abc@gmail.com asdasd
y Chrome abc@gmail.com dsadad

CreateLeadTest //Data provider is returning these values that do not have username and password
Runmode Browser LeadCompany LeadLastName
y Mozilla Techmahindra Kumar
n Chrome TCS Joseph

M
Replied on 27/07/2016

have you watched module 20?


M
Replied on 27/07/2016

Yes, I have watched Module 20 , Part 12. In this video data provider is used to get data for "CreateLeadTest" fro excel. The username and password column is mentioned under "loginTest". How does the data provider access column data from another test?


M
Replied on 28/07/2016

[quote:33r8330f]How does the data provider access column data from another test?
[/quote:33r8330f]

it does not. you have to write it again in excel sheet.


M
Replied on 28/07/2016

Ok. I have seen the complete video, username and password has not been declared again in "createleadtest". It is only mentioned in "logintest" and not written again for every testcase. Attached screenshot for reference.

Please clarify.


M
Replied on 28/07/2016

put username and password in create lead test too.

tell me if you need more clarification.


M
Replied on 31/07/2016

Since I have kept different priority to different test cases so want it to run like that. If I want to run end to end test then I will keep 'y' in excel sheet against all these test cases and it will run sequentially. If I want to run a specific test then I will put 'y' for that test and 'n' for the others.

The issue that I am facing is that when I am declaring String testCaseName = "CreateLeadTest"; in the class (not in @Test) the data provide is reading values frm that test only.

If I declare String testCaseName = "CreateLeadTest"; inside @Test then data provider is not reading the value and program do not compile.

How to input different testcase names so that data provider reads accordingly for different test cases.

Login test - Priority 1
create lead - priority 2
convert lead - priority 3


M
Replied on 31/07/2016

please contact me on skype qtpselenium1.