Passing command line arguments for Selenium Maven Testng



TestNG allows you to group your tests and also allows to pass Test Parameters using parameter tag in the TestNG xml file.
You can then execute one or more specific groups such as Sanity,Regression or Functional Tests based on the requirement and passing the parameter values to the testng.xml using maven-surefire-plugin via pom.xml the following configuration is helpful.

Passing the specific group name from the Command Line is achieved by updating the configuration of maven-sure-fire plugin as follows:

Maven Command Line:

Maven Command Line Arguments-Selenium,TESTNG

Maven Command Line Arguments-Selenium,TESTNG

Steps to achieve is mentioned as follows:

Like our Facebook Page to stay in touch with us. Happy Testing!!!!
https://www.facebook.com/totalqa

1. Create a Testng @Test program as follows.

2. Create an Grouping.xml file to invoke the Testng @Test Program.

3. Update the pom.xml as follows.

4. Download the apache maven software apache-maven-3.6.0-bin.tar.gz from this url https://maven.apache.org/download.cgi.

5. Set the classpath as follows.

Apache Maven Software Classpath

Apache Maven Software Classpath

6. Execute the following command from the command line.

Maven Command Line Arguments-Selenium,TESTNG

Maven Command Line Arguments-Selenium,TESTNG

Conclusion:

Passing the command line arguments is possible by using apache maven via pom.xml to the TestNG.xml

1 comment on “Passing command line arguments for Selenium Maven Testng

  1. Manuchehr Mirzoev

    Hi Sir, can you update your article? Some parts of the pom and grouping XML files are not visible and it is really difficult to figure it out.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *