Follow

XLS File As Data Provider

Use MS-Excel file(.xls) as data provider, you have to create excel file in resources folder.Below is the example of Excel data file for login scenario.

recId Username Password Isvalid ExpectedMsg
Wrong password chirag12 test123 false Invalid Username Or Password. Please Try Again.
Wrong User name and Wrong Password test wrongtest false Invalid Username Or Password. Please Try Again.
wrong Username chirag abc123 false Invalid Username Or Password. Please Try Again.

Note: If there are multiple data table in one excel sheet and user want the data from specific data table then user need to provide key which is 'data' in above example . User can configure that value by 'key' parameter of QAFDataProvider annotation.

The test case code will remain same only the change will be the parameter value of QAFDataProvider as shown below. User need to provide sheet name in the sheetName parameter if there are multiple sheets are available in one xls file.

    	@QAFDataProvider(dataFile = "resources/logindata.xls", sheetName="LoginSheet", key="data")
	@Test(description = "xls file as data provider ")
	public void login(Map <String, String> data) {
		doLogin(data.get("username"),data.get("password"), data.get("isvalid"));
		assertLoginMsg(data.get("expectedMsg"))
	}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk