【发布时间】:2021-12-07 22:36:55
【问题描述】:
我有以下几点:
describe('Page not authenticated', () => {
it('Page has authentication', () => {
cy.visit('https://myauthsite.com/logout');
cy.visit('/', { failOnStatusCode: true });
cy.url().should('include', 'https://myauthsite.com/');
});
})
出于内部原因,该软件包已设置为始终具有持久会话,因此我需要进行测试以访问特定 URL,该 URL 将显式注销并“终止”会话,然后访问我的主页我试图测试以确保它确实将我重定向到正确的页面。但是,我遇到了这个错误
You may only `cy.visit()` same-origin URLs within a single test.
The previous URL you visited was:
> 'https://myauthsite.com'
You're attempting to visit this URL:
> 'https://myactualsite.com'
You may need to restructure some of your test code to avoid this problem.
https://on.cypress.io/cannot-visit-different-origin-domain
列出的许多解决方法主要是地址检查属性而不是访问 url,或者将访问分成两个不同的测试用例,但在我的情况下,我真的需要它在自己的封装测试中,是不可能?
【问题讨论】:
标签: cypress