Parallel cross-browser testing using Selenium and TestNG without using testng.xml

I am using Maven Failsafe + TestNG to run Selenium tests. I know that you can pass parameters to my TestNG tests by defining the system properties in pom.xml as follows:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.19.1</version> <configuration> <systemPropertyVariables> <browser>firefox</browser> </systemPropertyVariables> </configuration> </plugin> 

My TestNG test refers to this property as follows:

 @Parameters("browser") public void setUpClass(@Optional("firefox") String browser) { ... } 

However, I was wondering if it is possible to run parallel browser tests in parallel without having to specify the testng.xml file. I tried something like this, but that didn't work. Please rate if you can help.

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.19.1</version> <configuration> <systemPropertyVariables> <browser>firefox, chrome</browser> </systemPropertyVariables> <parallel>tests</parallel> </configuration> </plugin> 

Is it possible to achieve this only with the pom.xml configuration? Due to the multi-module nature of my project, I do not really like to use the testng.xml file.

+5
source share
2 answers

You can fill in all the properties in the * .properties file, and then use it with the Maven Plugin Properties . QATools Properties will easily use them during driver configuration.

0
source

You can also run any TestNG test programmatically. Check TestNG Launch programmatically so from maven you just need to call your class using the main method having code to run testng programmatically and read any properties that you want to get from any source (csv, properties, xml, xlsx, etc.)

0
source

Source: https://habr.com/ru/post/1244333/


All Articles