Search code examples
seleniummavenenvironment-variablespom.xml

Maven - How to pass partial value in system property variables from POM.xml


here below is my url variable in pom.xml where i have to append qa value in ${evn} to run in different environment, i want to pass env alone from my url tag to pass on run time like below mvn clean test -Denv=qa my expectation to get url in test is like - https://www.qagoogle.com

  <systemPropertyVariables>
    <url>https://www.${env}google.com/</url>
  </systemPropertyVariables>

Solution

  • If you want to override the variable with -Denv you also need to add it to systemPropertyVariables

    <systemPropertyVariables>
        <env></env>
        <url>https://www.${env}google.com/</url>
    </systemPropertyVariables>
    

    and then, you can run mvn clean test -Denv=qa