gpt4 book ai didi

cucumber - 重复specflow中的步骤

转载 作者:行者123 更新时间:2023-12-02 03:57:37 25 4
gpt4 key购买 nike

我有一个很长的 Specflow 场景,我需要添加 3 个用户,所有步骤都是相同的。如何重复流程中的几个步骤?

场景大纲:向多个用户注册

Given Go to page
#Login
And Click on sign in button
When Enter email '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fc919d9590bc9b919d9590d29f9391" rel="noreferrer noopener nofollow">[email protected]</a>'
And Enter password '123456'
And Click on Submit button
And click on Events list button
And Open Event
And Go to new opened page
And Click on Register to event button

我需要重复这些步骤

When Click on Person title '<title>'    
And Select ticket package
And Select ticket quantity '15'
And Click on submit registration button
And Enter mail <email> to register to event
And Enter first name <first name> to register to event
And Enter last name <last name> to register to event
And Click on submit registration button
And Click on submit registration button
Examples:
| title | email | first name | last name |
| Person 1 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="402d21292c71002d21292c6e232f2d" rel="noreferrer noopener nofollow">[email protected]</a> | Person1 | Person1 |
| Person 2 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c3aea2aaaff183aea2aaafeda0acae" rel="noreferrer noopener nofollow">[email protected]</a> | Person2 | Person2 |
| Person 3 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="305d51595c03705d51595c1e535f5d" rel="noreferrer noopener nofollow">[email protected]</a> | Person3 | Person3 |

停止重复并完成场景

当点击“继续”按钮时那么列表中应该有 3 个用户

最佳答案

我所做的事情似乎对我来说效果很好

当注册多个用户“3”参加事件时,点击“人员”

[When(@"Register multiple users '(.*)' to event click on '(.*)'")]
public void WhenRegisterMultipleUsersToEventClickOn(int userQty, string title)
{
for (int i = 1; i <= userQty; i++)
{
WhenClickOnPersonTitle(title + " " + i);
WhenSelectTicketPackage();
WhenSelectTicketQuantity(10);
WhenClickOnSubmitRegistrationButton();
WhenEnterMailToRegisterToEvent("mail" + i + "@mai.com");
WhenEnterFirstNameToRegisterToEvent("Name" + i);
WhenEnterLastNameToRegisterToEvent("Lastname" + i);
WhenClickOnSubmitRegistrationButton();
WhenClickOnSubmitRegistrationButton();
}
}

关于cucumber - 重复specflow中的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43278925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com