Liondancer
Liondancer

Reputation: 16489

Using TestNG parameter values with other methods

I was wondering how I can use the parameters used for TestNG.

For example, if i have

@org.testng.annotations.Parameters(value = {"browser", "version", "os"})
public static foo() {
    ...
}

Can I pass these values somewhere else in the code to be used?

ex:

   System.out.println(value[0]);
   System.out.println(value[1]);
   System.out.println(value[2]);

Upvotes: 0

Views: 78

Answers (1)

thar45
thar45

Reputation: 3560

In the parameter argument list you should pass the mapping param names from XML file.you may not directly pass the values in the code.

@org.testng.annotations.Parameters({"browserType", "version", "os"})
public static foo(String browserType,Stirng version,String operatinSystem) {

can play with values inside the functions
    ...
}

This is format which TestNG Framework allows you handle with parameter class

Upvotes: 2

Related Questions