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

0
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

0
Best answer
0

You can pass parameters like this.

 

In class:

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

public class ParameterizedTest1 {
    @Test
    @Parameters("myName")
    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 "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
    <test name="test1">
	<parameter name="myName" value="manisha"/> 
	<classes>
	    <class name="ParameterizedTest1" />
	    </classes>
    </test>
</suite>

 

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

@Parameters({"myName1","myName2","myName3"})

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.
...