【问题标题】:Blocked a frame with origin "https://dev.*******" from accessing a cross-origin frame阻止来源为“https://dev.*******”的框架访问跨域框架
【发布时间】:2022-02-15 06:23:34
【问题描述】:

每当我运行此代码以在 cypress 上加载 iframe 时,我都会遇到错误。 阻止来源为“https://dev.expensa.me”的框架访问跨域框架。

cy.frameLoaded('#connect__iframe')

cy.iframe('#connect__iframe')
  .find('button_Continue')
  .click()

})

})

【问题讨论】:

  • 在问题中添加您遇到的错误的屏幕截图。
  • 你好@AlapanDas,我已经添加了我收到的消息。谢谢。

标签: javascript jquery css css-selectors cypress


【解决方案1】:

the Cypress documentation:

如果您的网站嵌入了一个跨域框架<iframe>, 赛普拉斯将无法自动化或与之通信 <iframe>.

跨域 iframe 的使用示例

  • 嵌入 Vimeo 或 YouTube 视频。
  • 显示来自 Stripe 或 Braintree 的信用卡表单。
  • 显示来自 Auth0 的嵌入式登录表单。
  • 显示来自 Disqus 的 cmets。

赛普拉斯实际上可以适应这些情况 与 Selenium 相同,但您将永远无法本地访问这些 来自 Cypress 内部的 iframe。

作为一种解决方法,您可以使用 window.postMessage 来 直接与这些 iframe 通信并控制它们(如果第 3 个 派对 iframe 支持)。

除此之外,您必须等待我们实施 API 支持这个(查看我们的open issue),或者你可以disable web security

【讨论】:

    猜你喜欢
    • 2019-02-05
    • 2017-06-25
    • 2017-04-03
    • 2013-10-14
    • 2015-07-29
    • 2018-05-31
    • 1970-01-01
    • 2020-12-11
    • 2019-04-27
    相关资源
    最近更新 更多