开发者

How to run one test against multiple sites using Selenium and TestNG

开发者 https://www.devze.com 2023-02-09 15:36 出处:网络
Given 3 web applications under test with given URLs: www.A.com www.B.com www.C.com How do I proceed to design a way using Selenium to run a single TestNG test against these three browsers and prin

Given 3 web applications under test with given URLs:

  • www.A.com
  • www.B.com
  • www.C.com

How do I proceed to design a way using Selenium to run a single TestNG test against these three browsers and print out the results.

Current Strategy:

I have a java class with a main method, a properties file containing the the 3 urls listed above.

In this class i have a while loop that parses these properties file like below snippet, and for each url, programmatically calls an ant task that automates the build from compilation to test-run to result archiving. The problem is that after the first run completes, it doesn't return to the while loop to do it again. You might ask why i want to run it three times. The idea as already explained is to be able to run a suite of tests against multiple websites automatically and printout 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();
    }

I hope somebody understands what am trying to do and can help me understand why the while loop terminates after the first test run. Also maybe can offer another easier strategy with TestNG.

thanks Guys. Y.ou guys Rock!!


It seems to me that if you are using ANT you shouldn't need your class. I would just use three targets and assign the different properties within those targets.

0

精彩评论

暂无评论...
验证码 换一张
取 消