Follow

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.

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

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

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 login.data is a key.

    	@QAFDataProvider(key = "login.data" )
	@Test(groups = { "SMOKE" },description = "xml file as data provider ")
	public void login(Map <String, String> data) {
		doLogin(data.get("Username"),data.get("password"));
		assertLoginMsg(data.get("isvalid"))
	}


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

 

SCENARIO: Login

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

                     'key': 'login.data' _&

                     }

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

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

END

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