Command:
mvn test -Dcucumber.options="--name 'Approve Rejected Creative'" -DEnvironment="Prod"
Feature file :
Given User launch "<Environment>" preflight
When User enters Email as "zzzz" and Password as "zzzz"
Then Click on Login
When User approves <creativeNumber> creative starting from row <startRow>
Then the creative should be approved
Step Def:
public void launchPreflight(String Env) {
// Set up WebDriver and launch the preflight URL
System.setProperty("webdriver.chrome.driver",
"/chromedriver/chromedriver");
driver = new ChromeDriver();
Env = System.getProperty("Environment");
if(Env.contains("Prod") || Env.contains("prod") || Env.contains("PROD")) {
driver.get(Prod_URL);
}
Getting below error : Errors: [ERROR] Cannot invoke "String.contains(java.lang.CharSequence)" because "Env" is null
I tried setting properties in the testrunner file but still the same. Am I missing something here, I am new to this code.
In scenario, you parameterized "Enviromnent"
but you are assigning environment value to null(Env is null).
Update in below way,
Scenario
Code