How to run a single test on multiple sites using Selenium and TestNG

For the three tested web applications with the given URLs:

  • www.A.com
  • www.B.com
  • www.c.com

How to move on to developing a way to use Selenium to run one TestNG test with these three browsers and print the results.

Current strategy:
I have a java class with the main method, a properties file containing 3 URLs listed above.
In this class, I have a while loop that parses these properties files, such as the snippet below, and programmatically calls the ant task for each URL, which automates the compilation from compilation for testing to lead to archiving. The problem is that after completing the first run, it does not return to the while loop to do it again. You may ask why I want to run it three times. The idea, as already explained, is to be able to run a test suite across multiple websites automatically and print the results without intervention.

Code snippet

        try {
        reader = new BufferedReader(new FileReader(new File(filename)));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    try {
           while((line=reader.readLine()) != null){             
            //call ant target to archive result
            userprops.setProperty("url", line);
            org.apache.tools.ant.Main.start(target, userprops, loader);
        }
    }catch (IOException e) {
        e.printStackTrace();
    }


, - , , , while . TestNG.

. Y.ou !!

+3
1

, ANT, . .

0

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


All Articles