简体   繁体   English

Selenium Webdriver:自动重复成功的方案

[英]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.

相关问题 使用Selenium WebDriver的Amazon登录和注销方案 - Amazon login and logout scenario using selenium webdriver 使用Selenium Webdriver(java)自动截取每个新页面的屏幕截图 - Automatically take a screenshot of every new page with Selenium Webdriver (java) 在使用Cucumber实现的相同方案中,我们如何利用Selenium WebDriver和Appium? - How can we make use of Selenium WebDriver and Appium in the same scenario implemented using Cucumber? 尝试一次仅运行5个线程的Selenium Webdriver,重复直到运行200个线程 - Trying to run only 5 threads of selenium webdriver at once, repeating until 200 threads have been run 我有一个搜索名称的场景,然后需要使用Selenium Webdriver从搜索结果中单击正确的名称 - I have a scenario where I search for a name and then I need to click on correct name from search results using selenium webdriver Webdriver异常-Selenium Webdriver Java - Webdriver Exception - Selenium Webdriver Java 自动重复本地通知? - repeating local Notifications automatically? 如何使用Java Selenium Webdriver Ashot FireFox自动对网页进行全屏拍摄,包括固定元素 - How to automatically take full screen shot of a webpage include fixed element using java selenium webdriver ashot firefox 无法自动选择文件 <input type=“file”> 通过使用Selenium Webdriver - Can't automatically choose file on <input type=“file”> by using Selenium Webdriver Java-Selenium Webdriver:在文本字段中输入文本,并自动从文本字段中删除 - Java - Selenium Webdriver: Entering text into text field, and removes automatically from the text field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM