Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

how to pass parameters using testng.xml

Solved 1 Answers 118 Views Selenium
0 1
I need to pass parameters using testng.xml. How do i do that?

1 Answer

Best answer

You can pass parameters like this.


In class:

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class ParameterizedTest1 {
    public void parameterTest(String myName) {
        System.out.println("Parameterized value is : " + myName);

In testng.xml


<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "" >
<suite name="Suite1">
    <test name="test1">
	<parameter name="myName" value="manisha"/> 
	    <class name="ParameterizedTest1" />


answered by (151 points)
commented by
Couldn't get this to work while passing multiple parameters.
commented by (151 points)
Try using {} for getting multiple parameters.


Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.