cypress: Browser not launched through Cypress problem
Current behavior:
When running any test using Chrome, the browser opens and shows the following message: This browser was not launched through Cypress. Tests cannot run., and a Run Chrome 64 button appears as well. Clicking the button launches the same browser again with the same message.
Desired behavior:
The test should be executed properly when running them on Chrome.
How to reproduce:
- Open cypress:
cypress open
- Select a test in the user interface and run it (Chrome selected as the browser) Notice that the tests don’t get executed
Test code:
Not relevant to the scenario. Same behaviour happen when running cypress examples.
Additional Info (images, stack traces, etc)
At the moment, in order to workaround this issue, I close the browser, run the test using Electron, the close it down and run again using Chrome. This way the test runs properly.
This happens when starting a new instance of cypress. After having it fixed through the workaround, the tests run properly regardless of if we close the browser or not.
I uninstalled Chrome and deleted all profile information, but the issue kept happening.
Note this issue is only happening on one machine. Any help to investigate would be appreciated.
- Operating System: macOS High Sierra. Version 10.13.2 (17C88)
- Cypress Version: 1.4.1
- Browser Version: Google Chrome Version 64.0.3282.119 (Official Build) (64-bit)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 42 (10 by maintainers)
So, the logs look pretty normal. 😞 Couple questions/comments.
File
->View App Data
so I did a little digging through cypress github issues and through interwebs and I found a solution that fixed my problem. the problem with this seemed to be with reaching any URL within browser, while browser itself had no problem opening.
I stumbled upon this and this issue and it seemed that some mess with localhost mapping was the core of the problem.
there is an
/etc/hosts
file on your Mac, (sorry Win guys if you have this issue too) that stores some data which probably some smarter guys than me should be able to explain. When I opened this, it was empty, so it might be a good idea to check it. I did a migration from old to new mac, so it seemed like a good idea to look for problems on default system configurations (not everything is migrated during migration apparently. I mean dude, where are my wifi passwords? ¯\_(ツ)_/¯).Anyway, since this file was empty, I basically looked what should be the defaults and copied them. Something like this:
sudo nano /etc/hosts
ctrl + X
theny
thenenter
)(you probably don’t need to copy the comments)
as I found out in those linked issues, Cypress apparently relies on this (probably the reason for throwing those
HEAD / 500
errors)Anyway, this worked for me and after two days of banging my head on the wall, I’m back writing my tests on a new mac 😄
Thanks @jennifer-shehane: Your solution worked for me. The reason I ended up with this issue was because of stopping a running test–> opening up the cypress app Goto File -> View App Data Delete everything in here Close cypress and open it up again And it should recreate all the browser profiles + extension
I was experiencing the same behavior. Deleting the Cypress folder in the ~/Library/Application Support
directory solved my problem.
We could generate a keypair and set the
key
in the extension’s manifest.json to our public key. That would guarantee that the extension ID would be static so users can whitelist it.Workaround 1: Using Electron instead of Chrome to run your tests can bypass this group policy.
Workaround 2: If you have Local Administrator access to your computer, you may be able to delete the registry keys that are blocking installing extensions in Chrome:
ExtensionInstallBlacklist
,ExtensionInstallWhitelist
,ExtensionInstallForcelist
,ExtensionInstallSources
, etc.)There is a related issue documenting efforts to bypass system policy settings within Cypress itself: #1253
just sharing my experience - when I test with older version of chrome, all good for couple hours.
but all of a sudden - I have the same error of
This browser was not launched through Cypress. Tests cannot run."
then the solution is - actually chrome updated itself and it seems to be the cause of this problem (I have also deleted “app data” in the cypress app as well)!!
so when I re-install older version of chrome, then it all works again!
FYI - if you want to disable auto update for chrome, this one works for me
Then close Chrome and Cypress and reopen
Browser not launching through Cypress. Seems to be related to corporate policy not allowing unpacked plugins, only whitelisted.
Could it be caused by the corporate policy? Is there a workaround, maybe adding the Cypress Extension ID to the corporate whitelist? Is there an ID that doesn´t change?
I had a similar issue when using Chrome Canary 73. However, my issue manifested in a slightly different way.
tldr; using electron or a non-canary build of chrome appears to have resolved my issue.
When hitting my local server (react app with react-router v4, running via webpack-dev-server with hot reload) on
https://localhost:8081
in a cypress test, my app would load but none of the Cypress tooling would appear. My app would also present a 404 page, saying that no route for/__
could be found (which is true, since I don’t have that route mapped). The below image is all I would see in the terminal that is running Cypress.However, if I hit my production app using Chrome Canary 73, Cypress & my tests loaded up just fine. So, I was going down a rabbit hole thinking that the issue was with my dev-server setup, but it turns out that the browser I was running Cypress in made the difference.
Note: the Cypress chrome extension in the Canary build did show up.
More info:
OS: Windows 7 Node: 8.11.1 LTS Npm: 5.8.0 Cypress: 2.1.0 Google Chrome: 65.0.3325.181
I did a clean install of Cypress:
When I open Cypress, this is the log’s output:
Notice the 500 errors. The Cypress app opens fine and when I click on the example test (example_spec.js), it opens the Google Chrome 65 browser, but nothing is showing (I see a white screen). The Cypress extension icon is not visible. If I enable the extension (it was disabled), and run the test again, I get again a white screen and now with the extension icon visible.
If I run the command using ./node_modules/.bin/cypress instead of npx, I get exactly the same error. If I run Cypress via “git bash”, or via Windows’s CLI, I get the error. I didn’t test this with Powershell. If I choose Electron option instead of Chrome, I get the same error.
I tested this also without VPN, without the Windows defender and Windows firewall enabled, without an active virusscanner (read: I disabled everything). Still I get this error.
Some debug logs:
If you’re deleting everything in App Data that’s exactly why it’s not working.
After you delete the App Data you need to close + reopen Cypress and it should recreate them. The extension is literally in App Data, so by deleting that you are nuking the extension, and thus you get the message.
For Windows 10, you can just copy all the logs, or if you’re using powershell redirect stdout / stderr to a file so you don’t have to copy and paste it all.