简体   繁体   English

Cypress - Chrome 扩展在 Cypress Test Runner iFrame 中不起作用

[英]Cypress - Chrome Extension not working inside Cypress Test Runner iFrame

I have a chrome extension that I successfully loaded into my Cypress environment.我有一个 chrome 扩展,已成功加载到我的 Cypress 环境中。 It shows up successfully in my extensions and I can see that it is turned on.它在我的扩展中成功显示,我可以看到它已打开。 I know it is working because I can open a new tab in the same browser where Cypress is running and it is working fine and making changes to the UI.我知道它正在运行,因为我可以在运行 Cypress 的同一个浏览器中打开一个新选项卡,它运行良好并且对 UI 进行了更改。

The problem is, the main tab that is running the Cypress Test Runner is inside of an iFrame and I suspect that the chrome extension I have loaded cannot interact with it.问题是,运行 Cypress Test Runner 的主选项卡位于 iFrame 内部,我怀疑我加载的 chrome 扩展无法与其交互。 I believe this issue reflects my problem . 我相信这个问题反映了我的问题 However, I tried that solution but with no luck.但是,我尝试了该解决方案但没有运气。

There is a blog that I stumbled upon that talks about a solution for fixing this for the React Dev Tools Extension . 我偶然发现了一个博客,它讨论了为React Dev Tools Extension修复此问题的解决方案。 The following screenshot explains:以下截图说明:

在此处输入图像描述

However, the extension that I am using does not have some kind of Global Hook like __REACT_DEVTOOLS_GLOBAL_HOOK__ that I can take advantage of as far as I can tell.但是,据我所知,我正在使用的扩展没有某种像__REACT_DEVTOOLS_GLOBAL_HOOK__这样的全局挂钩,我可以利用它。

I have no idea what to try next, if anyone can provide some guidance I would appreciate it.我不知道接下来要尝试什么,如果有人可以提供一些指导,我将不胜感激。

I ended up using Puppeteer for testing this particular extension.我最终使用Puppeteer来测试这个特定的扩展。 Puppeteer does not run within an iFrame allowing the extension to be testable, also you can integrate it into Cypress. Puppeteer不在允许扩展可测试的 iFrame 中运行,您也可以将其集成到 Cypress 中。 Its an annoying workaround but I'm not seeing a better way to do it.这是一个烦人的解决方法,但我没有看到更好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM