Follow

CSV File As Data Provider

Use csv file as data provider, you have to create csv file in resources folder.Below is the example of csv data file for login scenario in which first row is header.

	recId,Username,password,isValid,expectedMsg
	Wrong Password,admin,admin,false,Invalid Username Or Password. Please Try Again.
	Wrong Username and Password,Admin,Admin,false,Invalid Username Or Password. Please Try Again.
	Wrong Username,admin,admin123,false,Invalid Username Or Password. Please Try Again.
	

In the above data file we can see recId parameter. recId is predefined field of QMetry Automation Studio and can be used to identify test case in report. Below is the example of generated report.

Following is the testcase where CSV data provider used to provide set of data. The testcase is executed 3 times as there are 3 set of data in data file.@QAFDataProvider contain dataFile which contain path of csv file.

    	@QAFDataProvider(dataFile = "resources/logindata.csv")
	@Test(description = "login validation message " , groups={"p1" , "p2"})
	public void login(Map <String, String> data) {
		doLogin(data.get("Username"),data.get("password"));
		assertLoginMsg(data.get("isvalid"))
	}

Generated Report:

User can also provide CSV data value by any separator instead of comma (","). Use col.separator (predefined QMetry Automation Studio) to separate values. Below is the example to separate value by ("|").

	#col.separator = |
	Username|password|isvalid
	admin|admin|false
	Admin|Admin12|false
	admin|admin@123|true
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