Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we associate or link a tag on the feature file to the respective environment mentioned on serenity.conf? #3122

Closed
zgoveas opened this issue Apr 21, 2023 · 3 comments

Comments

@zgoveas
Copy link

zgoveas commented Apr 21, 2023

I have a feature file:

@stag Feature: This is just a demo

Scenario: Make sure the account is in online mode Given Adam needs to login to the demo page When he enables online mode Then he sees tests the demo logo

My serenity.conf file:

 environments {
 default 
 {
     webdriver.base.url = "https://default.demo.com"
 }
 local 
 {
     webdriver.base.url = "https://local.demo.com"
 }
 dev 
 {
     webdriver.base.url = "http://dev.demo.com"
 }
 staging 
 {
     webdriver.base.url = "https://staging.demo.com"
 }
 }

Is there a way to launch the browser with the appropriate URL? Maybe using the @before tag Or is there another simpler way?

I also understand that we can use command line mvn verify -Denvironment=staging, however is there another way without the use of command line? Mainly when I try to run a single scenario using right-click on a Scenario -> Run 'Scenario: Make sure the account is in online mode'

Tried the below code

 Before(value = "@Stag")
 @Given("^I am setting the environment$")
 public void setTheEnvironment()
 {         
    EnvironmentVariables env = SystemEnvironmentVariables.currentEnvironmentVariables();
    String baseUrl = EnvironmentSpecificConfiguration.from(env).getProperty("environments.staging.webdriver.base.url");
    env.setProperty("webdriver.base.url", baseUrl)  
 }

The above was not meant to work as I later found out that environment variables are ready only.

There also are potential solutions like create a custom property file like project.properties and use it map using JAVA code. But I just want to avoid the coding and understand if there is a direct way to relate @stag to environments.staging.webdriver.base.url

@globalworming
Copy link
Collaborator

with intelliJ you could try maven profiles https://www.jetbrains.com/help/idea/work-with-maven-profiles.html
it might work that you have different profiles that set different environment properties and then can toggle them easily for your Run 'Scenario

@Rangiferus
Copy link

Why don't you just add a line at the top of your serenity.conf and modify it depending on what environment you want to execute your tests on in IntelliJ:

environment = staging

@zgoveas
Copy link
Author

zgoveas commented May 9, 2023

Thank you for your quick response. We are going to use environment = staging when running our tests from command line

@zgoveas zgoveas closed this as completed May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants