XML File As Data Provider

     Use xml file as data provider, you have to create xml file in resources folder.Below is the example of xml data file for login scenario.

	<!--  data for login test -->
				<Username> admin </Username>
				<password> admin </password >
				<isvalid> false </isvalid >

				<Username> Admin </Username>
				<password> Admin </password>
				<isvalid> false </isvalid>
				<Username> admin </Username>
				<password> admin@123 </password>
				<isvalid> true </isvalid>
	<!-- file may contain other data -->

Following is the test case where XML data provider used to provide set of data. The test case is executed 3 times as there are 3 set of data in data file. Here you have to give key which is node of xml tree.In this example you can see is a key.

    	@QAFDataProvider(key = "" )
	@Test(groups = { "SMOKE" },description = "xml file as data provider ")
	public void login(Map <String, String> data) {

Same test case can be written with BDD approach as following. (Considering custom steps are built/written in java or bdd.)



Meta-data : {'desc': 'Login in to the application'; _&

                     'key': '' _&


       Given login with '${Username}' and '${password}'

       Then assert login success message with '${isvalid}'


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk