Let’s say I have two maven profiles for running projects web tests:
1. first deploys to CI tomcat instance with say http://ci.blahblah.com:8080 address and then tests are run
2. second profile for developers who can deploy to embedded tomcat using tomcat:run. So their address for web tests would be like http://localhost:8080
Now I created both profiles in pom file and in each of them in section <properties> I also created <base.url> property with different address for each profile.
Is there any way how I can now read these values into my java class where I launch web-tests using Webdriver so I could have sth like driver.get("address from pom <base.url>") ??
It simply allows developers to run web tests locally before commiting his/hers code.
You can use maven resource filtering. For instance:
First change your code so that it pulls the address from the properties file. Many ways to do this (reading the properties file directly, using spring propertyplaceholderconfigurer, etc)
Next create the properties file that will store this information, most likely in src/main/resources. Ensure that the value of your property uses the same name as your maven variable:
Ensure that filtering is setup in your profile as per the link above.