我有个问题。我使用Cypress实现自动化,我开始使用异步并等待测试。我正在使用POM设计模式。
我的问题是:如果我执行以下测试:
test.spec.ts类(测试类)
import { login_po } from "../pom/1.Chiquito/login_po";
const pom = new login_po()
describe("Put some name here.", async() => {
it('TestCase1', async () => {
await pom.navigateTo();
});
});
我的POM课。
export class login_po {
navigateTo() {
cy
.visit(`https://chiquito-qa.omnifitrgsites.co.uk/`)
.url()
.should('be.equal', 'https://chiquito-qa.omnifitrgsites.co.uk/').then(() => this.verifyAfterLogin());
}
verifyAfterLogin() {
cy.get('.header__logo-img');
}
}
当我执行测试时- Cypress做出4(相同)断言。
如果我从测试类中删除‘异步’-‘等待’,则Cypress做出1断言。
import { login_po } from "../pom/1.Chiquito/login_po";
const pom = new login_po()
describe("Put some name here.", () => {
it('TestCase1', () => {
pom.navigateTo();
});
});
为什么会发生这种事?
发布于 2021-12-23 15:55:47
Cypress命令不是承诺,以及它们与异步/等待的交互不会像您预期的那样发生。另外,虽然在柏树中使用POM是可行和合理的,但建议您使用Actions代替了POM。
https://stackoverflow.com/questions/70463901
复制相似问题