[英]Selenium Webdriver: Automatically Repeating a successful scenario
I use Selenium Webdriver tests based on Java/Gherkin/Cucumber. 我使用基于Java / Gherkin / Cucumber的Selenium Webdriver测试。
I have a test running that I want to run multiple times, without me having to restart the scenario several times. 我有一个要运行多次的测试,而不必多次重新启动该方案。
The Gherkin script is something like this: 小黄瓜脚本是这样的:
Given the user opens a browser
Then the user fills in the form
Then the user repeats the filling of the form *5* times
This way, if I want 10 forms to be filled in, I can just replace the 5 with 10, press play, and grab a beer. 这样,如果我想填写10个表格,我可以将5个表格替换为10个表格,按一下播放按钮,然后喝啤酒。
Is this at all possible or do I just have to re-run the scenario manually 5 times? 这完全有可能吗,还是我只需要手动重新运行该方案5次?
First you could simplify a bit your Gherkin scenario, like: 首先,您可以简化一下Gherkin的情况,例如:
Given the user opens a browser
Then the user fills in the form 5 times
Taking this scenario you then generate your methods and in the second method you can add a loop, like: 在这种情况下,您可以生成方法,并在第二种方法中添加一个循环,例如:
[Then(@"the user fills in the form (.*) times")] [然后(@“用户填写(。*)次表格”))
public void ThenTheUserFillsInTheForm(int nrOfTimes)
{
for(int i = 0; i < nrOfTimes; i++)
{
//user fills in the form
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.