首页 > 解决方案 > 赛普拉斯脚本 - 跨域 - iFrame 不加载

问题描述

希望一切都好。请为此请求您的帮助。我们正在执行一个启动 URL 1 - 的赛普拉斯脚本https://domain1.com。这个网站有一个iFrame嵌入式启动另一个网站 - https://domain2.com. 问题是,站点 2 没有在其中加载iFrame,我们不断收到消息 - “domain2.com 需要很长时间才能响应”。但是,如果我在 Cypress 之外启动https://domain1.comiFrame则会打开并成功启动 domain2 并显示。

我已经查看了几个帖子并执行了以下操作,

cypress.json "chromewebsecurity": false"modifyobstructivecode": false

index.js,然后是 package.json

const path = require('path');
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, args) => {
    console.log(config, browser, args);
    if (browser.name === 'chrome') {
      const ignoreXFrameHeadersExtension = path.join(__dirname, '../extensions/ignore-x-frame-headers');
      args.push(args.push(`--load-extension=${ignoreXFrameHeadersExtension}`));
      args.push("--disable-features=CrossSiteDocumentBlockingIfIsolating,CrossSiteDocumentBlockingAlways,IsolateOrigins,site-per-process");
    }
    return args;
  });
};

{
  "name": "coral",
 "version": "1.0.0",
  "description": "Coral testing",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "cy:run": "C:\\Testing\\Cypress\\Coral\\node_modules\\.bin\\cypress run",
                "download-extension": "ced gleekbfjekiniecknbkamfmkohkpodhe extensions/ignore-x-frame-headers"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cypress": "^4.1.0",
    "mochawesome": "^5.0.0",
    "mochawesome-merge": "^4.0.2"
  },
  "reporterEnabled": "mochawesome",
  "dependencies": {
    "file-system": "^2.2.2",
    "nodemailer": "^6.4.6",
    "chrome-ext-downloader": "^1.0.4"
  }
}

我已经下载了.crx此扩展的文件并将其重命名为ignore-x-frame-headers扩展目录下。

但是,每次我运行测试时,domain2.com 的页面都不会加载到iFrame.

有人可以解释我缺少/执行错误的步骤吗?非常感谢您的迅速和积极的回应。

在此先感谢,Karthik。

标签: iframecross-domaincypressloading

解决方案


推荐阅读