Open kuceb opened 6 years ago
Wow, this is an old thread... I have a need to "visit" a chrome-extension://
URL and load the extension in the current window. I don't need anything else and can run all of my tests once it's loaded. Nothing more, nothing less.
The more I dig in the code, it looks like this may be a change to https://www.npmjs.com/package/@cypress/request which seems to do the request and throw the error.
Furthermore, it seems like the maintainer wants people moving away from it https://github.com/request/request/issues/3142
The best thing for these new modules is for request to slowly fade away, eventually becoming just another memory of that legacy stack. Taking the position request has now and leveraging it for a bigger share of the next generation of developers would be a disservice to those developers as it would drive them away from better modules that don’t have the burden of request’s history.
Our team have successfully loaded the browser extension page in cypress:
The reason why chrome-extension:// is blocked: cypress runs in-browser and is blocked by chrome security policies
Solution: use puppeteer to control the browser behavior externally with CDP (Chrome Devtools Protocol), bypassing the security limitations.
Here's how to do it: Load the following code in cypress/plugins/index.js
const axios = require('axios'); const puppeteer = require('puppeteer'); . . .
This doesn't work. Even with the tweaks to get it to work with the latest puppeteer,await theFrame.goto
never completes and all you see is the following with an eventual timeout
Did you manage to make it work?
Support
cy.visit()
with protocols other thanhttp
/https
such as:chrome://
chrome-extension://
resource://
Most notably,
chrome-extension://
will allow users to test the UI of a chrome extension.