【问题标题】:Getting a cross origin error when running my Cypress tests in Jenkins在 Jenkins 中运行我的赛普拉斯测试时出现跨源错误
【发布时间】:2019-07-14 16:29:39
【问题描述】:

我在本地运行我的 Cypress,它们总是通过,但是当我在 jenkins 中运行它们时,我不断收到这个错误:


  > Blocked a frame with origin "http://localhost:3000" from accessing a cross-origin frame.

Before the page load, you were bound to the origin policy:
  > http://localhost:3000

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 routed you outside of your application
2. You submitted a form and your server redirected you outside of your application
3. You used a javascript redirect to a page outside of your application

Cypress does not allow you to change superdomains within a single test.

You may need to restructure some of your test code to avoid this problem.

Alternatively you can also disable Chrome Web Security which will turn off this restriction by setting { chromeWebSecurity: false } in your 'cypress.json' file.

https://on.cypress.io/cross-origin-violation

有时其中一个会通过 我试图将chromeWebSecurity: false 添加到我的 cypress.json 但登录测试后在我的网址中得到“数据:” (我正在注销不执行重定向的 api 调用)

【问题讨论】:

标签: jenkins automated-tests cross-domain subdomain cypress


【解决方案1】:

很可能有一些 javascript 调用 window.top.location 或其他形式的重定向。我们称之为framebusting,当您的应用退出其iframe 进入cypress 顶层框架时。赛普拉斯试图通过regex 删除此framebusting 代码,但代码可能会漏掉。

您应该:

  • 查找并禁用/删除 framebusting javascript
  • 在此处向 cypress 团队提交包含更多细节的问题

这里有一些与您类似的问题:https://github.com/cypress-io/cypress/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+framebust

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 2021-05-27
    • 1970-01-01
    • 2023-02-10
    • 2018-11-02
    • 2021-05-28
    • 2019-07-29
    相关资源
    最近更新 更多