我试图检查我是否在正确的页面上,但收到此错误:
expected '' to include http://localhost:4200
这是我的代码
`cy.visit('https://login');
cy.get('#username').type(username);
cy.get('#password').type(password);
cy.get('#kc-login').click()
cy.wait(7000)
cy.url().should('include', 'http://localhost:4200/machines')`
我不明白为什么我的字符串是空的
如果我不使用这个 cy.visit() ,我会遇到 cy.origin() 问题,而且我也不明白为什么我会遇到这个 cy.origin() 问题,因为我位于本地主机上。我没有导航到另一个页面。 我不想再使用 cy.origin() (我不明白为什么我必须使用它)并且我找到了
experimentalSkipDomainInjection
但仍然无法工作
我真的不知道该怎么办。请帮助我。
您的
cy.visit()
看起来像是拼写错误。
如果您使用
localhost
,您应该指定完整的 URL
cy.visit('http://localhost/login');
cy.get('#username').type(username);
cy.get('#password').type(password);
cy.get('#kc-login').click()
//cy.wait(7000) // don't do this
cy.url({timeout: 7000}).should('include', 'http://localhost:4200/machines')