Selenium 使用多个示例概述Java运行场景
有人能帮我找到以下用例的解决方案吗: 目前我正在使用Cucumber开发Selenium自动化,我有以下问题 我需要在web应用程序中自动化场景Selenium 使用多个示例概述Java运行场景,selenium,cucumber,scenarios,Selenium,Cucumber,Scenarios,有人能帮我找到以下用例的解决方案吗: 目前我正在使用Cucumber开发Selenium自动化,我有以下问题 我需要在web应用程序中自动化场景 Scenario Outline Login as "<User>" and purchase items and checkout by selecting "<Option>". Examples: |User| |Arun| |Ajay| |Ashok| Examples |Option| |one| |two| |T
Scenario Outline
Login as "<User>" and purchase items and checkout by selecting "<Option>".
Examples:
|User|
|Arun|
|Ajay|
|Ashok|
Examples
|Option|
|one|
|two|
|Three|
场景大纲
以“”身份登录并通过选择“”购买项目和签出。
示例:
|使用者|
|阿伦|
|阿杰|
|阿肖克|
例子
|选项|
|一个|
|两个|
|三|
在这里,我需要看到9次为每个用户运行相同的场景(选项3)
我的意思是,当Arun登录时,他应该签出并选择选项1(例如:他在未输入说明的情况下下下订单),然后再次Arun应该登录并签出并选择选项2(这次他输入说明并下订单),然后再次Arun作为选择选项3登录(例如:输入描述并选中一些复选框并下订单)
这需要对Ajay和Ashok也重复。我如何在Cucumber中实现这一点。我可以为单个场景大纲使用多个示例吗
或者有没有可能在背景中有一些例子
这是我需要自动化的重要用例之一,我一直在Cucumber中尝试各种选项,但都不起作用
提前感谢一个想法应该是这样的:
Scenario Outline: Login with purchase and checkout
Given I am on the login page
When I log in as "<User>"
And I purchase items
Then I can checkout using the "<Option>"
Examples:
| User | Option |
| Arun | one |
| Arun | two |
| Arun | three |
| Ajay | one |
| Ajay | two |
| Ajay | three |
| Ashok| one |
| Ashok| two |
| Ashok| three |
Scenario Outline: Checkout descriptions
Given I am logged in as "<user>"
And I have gone to the checkout after selecting various products
When I purchase the items
Then I should be able to checkout <with?> a description
Examples:
| user | with? |
| Arun | with |
| Ajay | with |
| Ashok | with |
| Arun | without |
| Ajay | without |
| Ashok | without |
Scenario Outline: Checkout with description and accept the terms of service*
Given I am logged in as "<user>"
And I have gone to the checkout after selecting various products
When I purchase the items
Then I should be able to checkout with a description
And I should be able to accept the terms of service*
Examples:
| user |
| Arun |
| Ajay |
| Ashok |
场景大纲:使用购买和签出登录
假设我在登录页面上
当我以“”身份登录时
我买东西
然后我可以使用“”进行签出
示例:
|用户|选项|
|阿伦一号|
|阿伦二号|
|阿伦|三|
|阿贾伊一号|
|阿杰二号|
|阿杰|三|
|阿肖克一号|
|Ashok | 2|
|Ashok |三|
这将为每个用户运行每个选项。我不知道您的代码看起来如何,但使用上面的格式应该很容易适应。请查看以及您可以编写下面给出的场景大纲。它可能很有用
Scenario Outline: Login as <user> and Purchase item with the option <option>
When I login as <user>
And I enter the description <description>
And I checkout the item using the option <option>
Examples:
|user|description|option|
|Arun |Some Desc|One |
|Arun | |One |
|Arun |Some Desc|two |
|Ajay | |three|
|Ajay |Some Desc|two |
|Ajay |Some Desc|three|
|Ashok| |One |
|Ashok|Some Desc|two |
|Ashok|Some Desc|three|
场景大纲:作为登录并使用选项购买物品
当我以
我输入描述
然后我使用选项签出项目
示例:
|用户|描述|选项|
|阿伦|一些描述|一|
|阿伦一号|
|阿伦|一些描述|二|
|阿杰| |三|
|有一些描述二|
|阿杰|一些描述|三|
|Ashok | | 1|
|Ashok |一些描述|二|
|Ashok |一些描述|三|
这将使用不同的用户、描述和选项运行所有步骤。您的步骤和场景大纲似乎做得太多了 如果用户具有明确不同的权限,或者3个用户中的每一个用户的签出方法都发生了变化,那么当然,测试可能需要9个场景,如果没有,您可能只需要编写3个场景来测试 我编写此测试的方式:
Background:
Given I am logged in as "Arun"
And I have gone to the checkout after selecting various products
When I purchase the items
Scenario Outline: Checkout descriptions
Then I should be able to checkout <with?> a description
Examples:
| with? |
| with |
| without |
Scenario: Checkout with description and accept the terms of service*
Then I should be able to checkout with a description
And I should be able to accept the terms of service*
背景:
鉴于我以“Arun”身份登录
在选择了各种产品之后,我去了收银台
当我购买物品时
场景大纲:签出描述
然后我应该能够签出一个描述
示例:
|用什么|
|与|
|没有|
场景:使用说明签出并接受服务条款*
然后,我应该能够结帐与描述
我应该可以接受服务条款*
*将“接受服务条款”替换为选中复选框后的含义
Gherkin的存在是为了弥合开发团队和业务之间的对话鸿沟,因此确保所使用的语言能够被非技术业务人员理解是至关重要的。在功能文件中不要包含实现细节,因为它只是描述系统的行为
编辑
如果在其他2个用户之间运行测试有真正的业务好处(而且运行测试不仅仅是为了设置测试数据,这应该在before钩子中完成),那么您可能需要执行以下操作:
Scenario Outline: Login with purchase and checkout
Given I am on the login page
When I log in as "<User>"
And I purchase items
Then I can checkout using the "<Option>"
Examples:
| User | Option |
| Arun | one |
| Arun | two |
| Arun | three |
| Ajay | one |
| Ajay | two |
| Ajay | three |
| Ashok| one |
| Ashok| two |
| Ashok| three |
Scenario Outline: Checkout descriptions
Given I am logged in as "<user>"
And I have gone to the checkout after selecting various products
When I purchase the items
Then I should be able to checkout <with?> a description
Examples:
| user | with? |
| Arun | with |
| Ajay | with |
| Ashok | with |
| Arun | without |
| Ajay | without |
| Ashok | without |
Scenario Outline: Checkout with description and accept the terms of service*
Given I am logged in as "<user>"
And I have gone to the checkout after selecting various products
When I purchase the items
Then I should be able to checkout with a description
And I should be able to accept the terms of service*
Examples:
| user |
| Arun |
| Ajay |
| Ashok |
场景大纲:签出说明
假设我以“”身份登录
在选择了各种产品之后,我去了收银台
当我购买物品时
然后我应该能够签出一个描述
示例:
|用户|与|
|阿伦|
|Ajay |与|
|阿肖克|
|阿伦|无|
|阿杰|没有|
|Ashok |无|
场景概述:签出并说明接受服务条款*
假设我以“”身份登录
在选择了各种产品之后,我去了收银台
当我购买物品时
然后,我应该能够结帐与描述
我应该可以接受服务条款*
示例:
|使用者|
|阿伦|
|阿杰|
|阿肖克|
谢谢。是的,我以前试过,效果很好。但这里我有更多的用例可以为每个用户登录自动执行,例如:场景Ou TLINE for EG:我需要自动执行一个场景,当Arun登录时,他需要使用选项1签出并从顶部图表中选择项目。然后下订单。然后再次Arun登录并选择选项1并选择它m从搜索文本字段中选择并下订单。这样我就有4种方法来选择项目。因此,让我在这里更清楚地说明每个用户将有16个用例。是否有任何方法可以使用示例或背景来实现这一点。|用户签出选项项目选择Arun zero zero one 2在这个Arun登录中有两个Ajay zero zero one,并选择了签出选项zero和签出选项zero,他需要为Items selection下的所有三个选项进行选择,更重要的是,他应该为item selection下每个订单。在我看来,您似乎试图在单个场景中添加太多的用例提纲。为什么不创建多个?对所有参与的人来说都有更好的可读性。谢谢。是的,我已经像上面提到的那样写了我的场景。但是我想把它浓缩成更多的内容