Parameterization in TestNG using testng.xml

August 21, 2016

Using testng.xml file we can also pass values to the argument of any test case or method. @Parameters annotation is used to pass parameters to a test case or method. Let us consider an example where we have written a test case say invokeBrowser which accepts an argument browserType. Based on the value passed respective Browser is invoked.

In testng.xml file a tagname called parameter is used which has an attribute called name and another its value.

Below is the example for testng.xml file:

Let us see the code for same:

Here, an attribute called sBrowserType accepts value from an attribute BrowserType passed as firefox from testng.xml file.

If a method has multiple arguments, values from parameter attribute are accepted in sequential order.

PS: For any questions queries or comment feel free to write us at saurabh@qatechhub.com or support@qatechhub.com. Happy Learning 🙂

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra:

Leave a Comment: