[英]How to run one test against multiple sites using Selenium and TestNG
Given 3 web applications under test with given URLs: 给定3个具有给定URL的Web应用程序:
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.