cypress: Chrome cy.visit breaks testpage, but works in Electron
Current behavior:
When running a cy.visit in Chrome 74 the testpages turns nearly blank and displays Cannot GET /__/
.
However it does visit the page when Electron is used.
1. Running test
2. Redirect?
Config
Desired behavior:
The cy.visit()
call should show the served page at localhost:8080
in an iframe.
The testpage should stay visible (as seen in screenshot 1).
Steps to reproduce:
The following test redirects to the page shown in the screenshot:
cy.visit('http://localhost:8080/index-mocks.html');
Versions:
Windows 10
$ ./cypress --version
Cypress package version: 3.3.0
Cypress binary version: 3.3.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 37 (11 by maintainers)
@RicardoVaranda You may be able to delete the policy yourself if you have local administrator access.
Sidebar: It’s especially unfortunate that so many companies have this policy set, as forcing a proxy is basically just security theater. It does nothing to make you more secure. Users can get around being forced to use a proxy by using other browsers that don’t respect policy, like SRWare Iron, or by injecting a DLL that blocks the policy. Of course, your company’s network will not allow Internet access without going through the proxy, which also makes forcing ProxyMode redundant. 🙄
We have also been facing this issue for quite some time now and had to use electron to bypass it. It would be great to get a fix.
I also tried Chrome Portable and it was also overtaken by my organization - which seems kinda strange, 'cause portable version of the browser should not use the settings in registry. I am currently using Electron but I will try to work on this topic when I have more time.
Thank you all for your engagement in solving the problem. Keep up the good work!
This is interesting, thank you for discovering this discrepancy. Remote Address should be the
host:port
of Cypress’s proxy server, not thehost:port
of the AUT; that makes me think that somehow we’re not passing the correct proxy server to Chrome in certain situations.@wojciechsabaj Can you could supply the
DEBUG
logs for when you use Electron vs when you use Chrome? That should narrow it down and allow me to find the source of the bug. Note, these are not the debug logs from the browser console, but the debug logs that you get in the command line. Something like this should work:I’m also wondering if this could be #1253 in action - corporate policy preventing us from setting the proxy Cypress needs. Could you share screenshots of
) and of
chrome://policy/
(after clickingchrome://net-internals/#proxy
from the browser launched by Cypress?@jennifer-shehane
Thanks for your reply, we have previously tried setting the baseUrl but it comes out to the same result, if we use the built in Electron it visit the page fine and runs the tests, if we run it within Chromium it breaks out of the test interface, it starts off trying to access:
http://localhost:4201/__/#/tests/integration\regression\user.js
and then gets redirected to:
http://localhost:4201/__#/tests/integration%5Cregression%5Cuser.js
This route obviously doesn’t exist within our app and redirects to a 404 page.
The top url reloads when you do not have a
baseUrl
set, Cypress has no idea what url you are planning to visit before it reaches thecy.visit()
command - when it reaches the url there, it reloads the page so that the top domain is the domain you are visiting.You can read more about this intended behavior here: https://on.cypress.io/best-practices#Setting-a-global-baseUrl
Hi @jennifer-shehane, I also experienced the same behaviour as other people commenting here (@RicardoVaranda, @MrMinimal).
If I am correct, the problem is with setting “top” window.
Here is the test (no rocket science in here):
I would really like to post the screenshots but the corpo firewall is blocking my connection, so I will describe the situation:
In Electron => Dev Tools => Sources I see the following:
top => www.google.pl => => __ => => => (index) => => __cypress/runner => (no domain) => Your App: blahblahblah => Your Spec: blahblahblah
When I open (index), I see the following info inside:
This is probably the part that is failing in Chrome and working in Electron.
When I start test in Electron, I see that the test is running and request to “https://www.google.pl/__” is performed but then the whole Cypress environment inside browser is reloaded and then the test is being run again, that time (I suppose) the ‘top’ is set correctly and request to “https://www.google.pl” is sent correctly and page is displayed correctly.
When the test is started in Chrome, all I see is the request sent to “https://www.google.pl/__” and the famous 404 error:
“The requested URL /__/ was not found on this server. That’s all we know.”
I hope that my description will help you guys with fixing the problem. Cypress is a great framework, although it has some limits imposed by its creators. I was thinking that such requests to Google are outright blocked but it seems to be a problem with Chrome, not with Cypress.
Keeping my fingers crossed for fixing this problem.
Wojtek