use*_*788 2 cucumber feature-file cypress
我在 Cypress 框架中使用功能文件。
下面是一个场景示例:
Scenario: #1 Cancel should return to Customer Management landing page
Given User is on the Edit Customer Page
When User updates the email address to "abc@gmail.com"
Then the updated email address will appear on the summary page
Run Code Online (Sandbox Code Playgroud)
我面临的问题是,当我重新运行此测试时,原始电子邮件地址将是“abc@gmail.com” (在第一次测试运行期间更新为的值)。因此测试实际上不会更新电子邮件地址。
处理这个问题的最佳方法是什么?
我正在考虑使用类似功能的Before()功能来删除客户(如果存在),然后重新创建它。然后我就可以更新它并且每次的值都是相同的。
但是,我不知道如何Before()在功能文件中添加 a 。我有一个Background可以导航到某个页面的页面,但那是我应该放置它的地方吗?
TheBrainFamily 推荐使用Give
请参阅步骤定义
这是放置与该特定功能相关的before/ beforeEach /after/afterEach 挂钩的好地方。对于纯黄瓜来说,这是非常困难的。
所以
import { Given } from "cypress-cucumber-preprocessor/steps";
const url = 'https://google.com'
Given('User is on the Edit Customer Page And Email is empty', () => {
beforeEach(() => {
// reset email
})
...
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8212 次 |
| 最近记录: |