1

I would like to share a constant variable over multi-tests in selenium For example String text = "the shared text over tests";

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.