How to substitute the environment variable in the parameter defined in the .properties file
We have 2 test environments qa1 and qa2. Based on what we have defined in the Run/Debug configurations we either use qa1.properties file or qa2.properties file. We use Java, Selenium and IntelliJ IDEA IDE. I have defined the ENV_NAME=qa2 in the qa2.properties file
Within each of these properties file we have URLs defined. As an example in qa1.properties file we will have LOGIN_URL=https://demo.testing.com/vp-clientlib-v1.php?env=qa1 and the same URL in qa2.properties file we will have LOGIN_URL=https://demo.testing.com/vp-clientlib-v1.php?env=qa2
As you see, the environment is hardcoded. I am trying to substitute the ENV_NAME in the URL but haven't been successful so far. Could you please help me.
Please have a look at Apache Configuration. It supports Variable Interpolation.
If you like to set ENV_NAME as a OS enviornment variable ENV_NAME=xyz
your property will be written like
LOGIN_URL=https://demo.testing.com/vp-clientlib-v1.php?env=${env:ENV_NAME}
If you set ENV_NAME=xyz
as property in the property file than you would write
LOGIN_URL=https://demo.testing.com/vp-clientlib-v1.php?env=${ENV_NAME}
Beside this Apache Configuration provides a lot of other cool stuff for flexible property definition.