gpt4 book ai didi

selenium - 如何使用场景作为另一个场景的先决条件

转载 作者:行者123 更新时间:2023-12-04 10:29:05 26 4
gpt4 key购买 nike

第一个特征文件

Feature: CRMSmokeTest
In order to make sure that CRM Key functionalities working as expected.
Background:
Given I have entered the CRM URL

Scenario Outline:Quick Search using AccountID
Given AccountID is selected in The Quick Search
When user enter the <AccountID> in search field
And Click on Quick Search button
And Close the Alerts
Then Title of the page contains <AccountID>
Examples:
| AccountID |
| 116999 |

第二个特征文件
Feature: CRM Ticket Open, Add and Amend
In order to verify thay user able to open and amend existing ticket
Also to verify that user is able to create a new Ticket
Background:
Given I have entered the CRM URL
And AccountID is selected in The Quick Search
@mytag
Scenario Outline: Add a new Ticket
When user enter the <AccountID> in search field
And Click on Quick Search button
And Close the Alerts
Then Title of the page contains <AccountID>
When User click on Add New link on Ticket Section
And Select the <Departmnet> and <SubTeam> from the list
And Enter the <Subject> of the ticket
And Select the <Product>
And Select the <TicketCategory> and <TicketSubCategory>
And Enter the <Comments> and <PersonSpokeTo>
And Click on Finish
Then A new Ticket is created
Examples:
| AccountID | Department | SubTeam | Subject | Product | TicketCategory | TicketSubCategory | Comments |
| 116999 | Customer Services | ContractEnquiry | Test Ticket | Home Insurance | Account Management | Customer Zone | Test Comments |

我想在我的第一个功能文件中使用场景作为我在第二个功能文件中的场景的先决条件。
  • 这样做的最佳做法是什么
  • 此外,在填写大数据表单时,编写场景的最佳方法是什么。我在第二个功能文件中编写场景的方式是唯一的方法,还是我们可以编写更好的方法?
  • 最佳答案

    调用不同的场景,因为它满足当前场景的先决条件,打破了使每个场景可独立运行所需的隔离。任何场景都不应依赖于任何其他场景。

    不要复制和粘贴第一个场景中的步骤,而是写一个简短的 Given执行与第一个场景相同的事情的步骤。

    根据场景标题,创建一个 Given步骤类似于:

    Scenario Outline: Add a new Ticket
    # New 'Given' step that basically does the same thing as scenario #1
    Given user performed a quick search for account <AccountID>

    # Now continue on with the rest of the scenario
    When User click on Add New link on Ticket Section
    And Select the <Departmnet> and <SubTeam> from the list
    And Enter the <Subject> of the ticket
    And Select the <Product>
    And Select the <TicketCategory> and <TicketSubCategory>
    And Enter the <Comments> and <PersonSpokeTo>
    And Click on Finish
    Then A new Ticket is created

    Examples:
    | AccountID | Department | SubTeam | Subject | Product | TicketCategory | TicketSubCategory | Comments |
    | 116999 | Customer Services | ContractEnquiry | Test Ticket | Home Insurance | Account Management | Customer Zone | Test Comments |

    此步骤的实现将取决于您的测试架构,但该步骤应该:
  • 转到 CRM URL
  • 在快速搜索中选择 AccountId
  • 在搜索框中输入给定的帐户 ID
  • 点击快速搜索按钮
  • 出现时关闭警报

  • 如果您发现自己编写的代码似乎存在于其他步骤中,请考虑将您的代码重构为 Page Models ,然后初始化这些页面模型并从您的步骤定义中调用它们的方法。测试的基本控制流程将是:
    Feature file --> Step definition --> Page model --> Selenium --> Web browser

    关于selenium - 如何使用场景作为另一个场景的先决条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60494385/

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