【发布时间】:2021-10-25 20:54:50
【问题描述】:
我正在尝试使用柏树和黄瓜验证对话框上的短信。当测试用例在“它的功能”内时,它工作得非常好。这是示例代码:
it ('Verify if the Login is successful', function()
{
cy.visit('loginTest.html')
cy.get('#username').type('shahin')
cy.get('#password').type('tala')
cy.contains('Login').click()
cy.on('window:alert', (str) => {
expect(str).to.equal(`Login Successfully`)
})
})
但是,当我添加 BDD 关键字时,看起来该函数根本没有得到评估。 它适用于 When 但不适用于 Then 场景。我认为它需要在 Js 中以不同的方式处理。我也上传了柏树日志。下面是代码:
When('I click on the login button', () => {
cy.contains('Login').click()
})
Then('Successful POP up message should be displayed', () => {
cy.on('window:alert', (str) => {
expect(str).to.equal(`Login Successfully`)
})
赛普拉斯日志
【问题讨论】: