how to pass parameters using testng.xml

Solved 1 Answers 110 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 "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
    <test name="test1">
	<parameter name="myName" value="manisha"/> 
	    <class name="ParameterizedTest1" />


answered by (192 points)
commented by
Couldn't get this to work while passing multiple parameters.
commented by (192 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.

We have resolved 1.2k+ Software Testing queries!

Top Contributors