Reputation:
I would like to share a constant variable over multi-tests in selenium
For example String text = "the shared text over tests";
Upvotes: 1
Views: 2061
Reputation: 944
You can define your class of constants like this:
public class Constants {
// now here you can define your constant variables
public static text = "the shared text over tests";
}
now, you can use your constant variable in any class of your package like this:
String constantText = Constants.text;
Upvotes: 0
Reputation: 4662
You can define it a class containing all your shared stuff:
public class TestConstants {
public static final String SHARED_TEXT = "My shared text";
}
and then in your tests you can simply reference it as:
TestConstants.SHARED_TEXT.equals(actualText);
or however you need it to
Upvotes: 1