Thursday 3 April 2014


TestNG Parameterized Test using xml file

In last article we have discuss how to parametrized test using @DataProvider annotation in TestNG. 

In this blog lets discuss how to pass parameter in test from xml file. First create a xml file in root dir of your project and named it TestNG.xml



Now write TestNG.xml as shown below
Now we have xml ready and its time to write tests , parameter define in xml (in green background) will be pass in tests and on the basis of this parameter  specific browser will be open. Lets create a class which will be responsible to open and close browser.

Now create tests. Here is first test i.e. 'LoginTest', make sure that it should be in 'package1' as we have mention it in xml as well.




Here is another two tests which is in 'package2' named 'CountEmail' and 'ComposeEmail'
 
*CountEmail



*ComposeEmail


Its time to run test, so do right click on TestNG.xml file and click on Run as TestNg Suite. LoginTest will run on firefox browser because value of browser is set to firefox in TestNG.XML and we are checking that value in 'LaunchCloseBrowser' and in the same manner other both tests will execute on chrome broswer.



No comments:

Post a Comment