小编Bil*_*ayo的帖子

赛普拉斯e2e测试-如何解决跨源错误?

我正在测试一个集成了Gmail,Slack,Dropbox等的Web应用程序。我正在尝试使用Cypress.io编写端对端测试,以验证身份验证流是否正常运行。赛普拉斯(Cypress)限制了我浏览我应用程序域之外的内容,并给了我一个跨源错误。赛普拉斯(Cypress)的文档说,测试不应该涉及在应用程序外部进行导航。但是测试我的应用程序的全部目的是确保这些外部身份验证流正常运行。

文档还说您可以在cypress.json文件中添加“ chromeWebSecurity”:false来解决此限制。我已经做到了,但仍然遇到跨原点错误(这是我问题的核心。理想情况下,我会绕过此限制)。

我尝试过赛普拉斯的单点登录示例。https://github.com/cypress-io/cypress-example-recipes#logging-in---单点登录 我无法使其工作,并且它的代码比我认为的要多得多。

我已经在github中对此线程发表了评论,但是还没有任何回应。

完整的错误消息:

Error:     CypressError: Cypress detected a cross origin error happened 
on page load:

  > Blocked a frame with origin "https://www.example.com" from 
accessing 
    a cross-origin frame.

    Before the page load, you were bound to the origin policy:
      > https://example.com

A cross origin error happens when your application navigates to a new 
superdomain which does not match the origin policy above.

This typically happens in one of three ways:

1. You clicked an <a> that …
Run Code Online (Sandbox Code Playgroud)

e2e-testing cypress

6
推荐指数
3
解决办法
1406
查看次数

标签 统计

cypress ×1

e2e-testing ×1