Showing posts with label @Parameters. Show all posts
Showing posts with label @Parameters. Show all posts

Monday, May 12, 2014

How to pass the Data to test script through xml or How to use @Parameters in TestNG ?

Ans- use @Parameters to pass the input through xml.

Ex-

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

public class PassInputThruXML {
@Test
@Parameters({"para1","para2"})
public void passInput(String para1, double para2){
    System.out.println(para1);
    System.out.println(para2);
}
}


testng.xml->


<suite name="Suite" parallel="none">
  <test name="Test">
    <parameter name="para1" value="selenium-makeiteasy" />
    <parameter name="para2" value="5.0" />
      <classes>
          <class name="TestNg.PassInputThruXML"/>
      </classes>
  </test>
</suite>