我使用基于Java/Gherkin/Cucumber的Selenium Webdriver测试。
我有一个测试运行,我想运行多次,而不需要重新启动场景几次。
Gherkin脚本是这样的:
Given the user opens a browser
Then the user fills in the form
Then the user repeats the filling of the form *5* times 这样,如果我想填写10份表格,我可以用10代替5,按下播放,然后拿一杯啤酒。
这有可能吗?还是只需要手动运行5次?
发布于 2015-04-24 17:07:34
首先,您可以简化一些Gherkin场景,比如:
Given the user opens a browser
Then the user fills in the form 5 times在这个场景中,您将生成您的方法,在第二个方法中,您可以添加一个循环,例如:
然后(@“用户填写表单(.*)时间”)
public void ThenTheUserFillsInTheForm(int nrOfTimes)
{
for(int i = 0; i < nrOfTimes; i++)
{
//user fills in the form
}
} https://stackoverflow.com/questions/29163294
复制相似问题