硒 + TestNG测试一系列网页
我刚刚开始使用 TestNG 和 Selenium
我想在一组网页中执行注册测试。 我用以下方法编写了一个 Register 类
@Test( dataProvider = "WebSites", groups = "launchSite")
public void launchSite(WeboSite webSite)
@Test( dataProvider = "WebSites", groups = "goToRegPage",
dependsOnGroups = "launchSite")
public void openRegisterPage(WeboSite webSite)
@Test( dataProvider = "WebSites", groups = "register",
dependsOnGroups = "goToRegPage")
public void enterRegistrationData(BingoSite bingoSite)
,因此我使每个测试都依赖于前一个测试(显然,如果您无法进入注册页面,则无法注册) 我现在想要的是每个网页结果都独立于其他网页结果。 现在,openRegisterPage 会针对每个网页运行,如果在一个网站中失败,enterRegistrationData 不会为其中任何一个网页运行。
这样做的正确方法是什么?
多谢
I'm just starting with TestNG and Selenium
I want to perform a registration test in a collection of webpages.
I've writen a Register class with the following methods
@Test( dataProvider = "WebSites", groups = "launchSite")
public void launchSite(WeboSite webSite)
@Test( dataProvider = "WebSites", groups = "goToRegPage",
dependsOnGroups = "launchSite")
public void openRegisterPage(WeboSite webSite)
@Test( dataProvider = "WebSites", groups = "register",
dependsOnGroups = "goToRegPage")
public void enterRegistrationData(BingoSite bingoSite)
So I've made each test dependant on the previous (obviously if you cannot enter the registration page you cannot register)
What I want now is each webpage result be independant from the others.
Now openRegisterPage is run for every webpage and if it fails in one website enterRegistrationData is not run for any of them.
What is the correct way to do this?
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果一个方法失败,所有依赖它的方法都将被跳过,这就是这个功能的重点。
如果您想要的话,您可以在enterRegistrationData上指定alwaysRun=true(从您的问题中不太清楚)。
If a method fails, all the methods that depend on it will be skipped, that's the point of this feature.
You can specify alwaysRun=true on enterRegistrationData, if that's what you want (not quite clear from your question).