简体   繁体   English

如何使用Selenium和TestNG对多个站点运行一个测试

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

Given 3 web applications under test with given URLs: 给定3个具有给定URL的Web应用程序:

  • www.A.com www.A.com
  • www.B.com www.B.com
  • www.C.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. 如何使用Selenium设计一种方法,针对这三种浏览器运行单个TestNG测试并打印出结果。

Current Strategy: 现行战略:
I have a java class with a main method, a properties file containing the the 3 urls listed above. 我有一个带有main方法的java类,一个包含上面列出的3个url的属性文件。
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. 在这个类中,我有一个while循环,它解析这些属性文件,如下面的代码片段,对于每个url,以编程方式调用一个ant任务,自动化构建从编译到测试运行到结果归档。 The problem is that after the first run completes, it doesn't return to the while loop to do it again. 问题是在第一次运行完成后,它不会返回到while循环再次执行它。 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. 我希望有人理解我想要做什么,并且可以帮助我理解为什么while循环在第一次测试运行后终止。 Also maybe can offer another easier strategy with TestNG. 也许可以使用TestNG提供另一种更简单的策略。

thanks Guys. 多谢你们。 Y.ou guys Rock!! 你们好棒!!

It seems to me that if you are using ANT you shouldn't need your class. 在我看来,如果你使用ANT,你不应该需要你的课程。 I would just use three targets and assign the different properties within those targets. 我只想使用三个目标并在这些目标中分配不同的属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用testng并行运行我的硒测试方法 - how to run my selenium test methods in parallel using testng 如何使用TestNG在selenium WD中使用一个登录测试用例运行多个测试用例 - How to run multiple testcase with One login testcase in selenium WD with TestNG 如何使用页面工厂在testng中运行多个测试类? - How to run multiple test classes in testng using page factory? 使用Testng作为套件运行多个Selenium Java测试用例 - Run multiple selenium java test cases as suite with Testng 在 Selenium 中使用 Java 是否可以在 testNG 中仅编写一种测试方法并从中形成多个测试? - In Selenium using Java is it possible to write only one test method in testNG and form multiple tests from it? 如何在多台服务器上的IE中并行运行TestNG / Selenium测试套件? - How can I run a TestNG/Selenium test suite in IE on multiple servers in parallel? 如何使用TestNG并行运行Selenium? - How to run Selenium in parallel using TestNG? 使用testng |并行运行硒测试用例 专家 - Run selenium test cases in parallel, using testng | maven 如何仅使用一个Web驱动程序实例在testng套件中运行多个测试类? - How to run multiple test classes in testng suite with only one web driver instance? 如何使用@BeforeSuite批注使用Selenium + TestNG运行多个浏览器会话(并行执行) - How to run multiple browser sessions (parallel execution) with Selenium + TestNG using @BeforeSuite annotation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM