Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress cy.visit redirects to HTML and is unable to load main.js / Cypress UI lost #3124

Closed
ethernal opened this issue Jan 13, 2019 · 11 comments
Assignees
Labels
browser: chrome type: bug type: duplicate This issue or pull request already exists

Comments

@ethernal
Copy link

ethernal commented Jan 13, 2019

Is this a Feature or Bug?

Bug. Possibly in my configuration. I did post a question on gitter and was without answer. Also it seems that more context will be beneficial so using GitHub for it.

Current behavior:

When running npm run server and then npm run cypress from https://github.com/ethernal/react-boilerplate and selecting smoketest_homepage_spec.js Cypress runs and redirects to the page with 'Hello World'. No JS is loaded so the App and styles are not loaded.

Also there is no Cypress UI/console (framebusting?).

Video (MP4) file in ZIP as MP4 are not supported.

cypress-react-app-redirect-and-ui-lost-video.zip

When running localhost manually it loads OK (console tab)..
cypress-browser-manually-run-localhost-console-tab png

..and Network tab:
cypress-browser-manually-run-localhost-network-tab

When run by Cypress it cannot find the main.js served by WDS from memory:
cypress-chrome-unable-to-find-main-js

This is URL copied to Firefox:
localhost-server-accessed-from-firefox

Running Cypress in debug/log (localStorage.debug='cypress/*' in console) mode shows:

GET http://localhost:8080/__/main.js net::ERR_ABORTED
Navigated to http://localhost:61036/__/
VM47 cypress_runner.js:153927 Download the React DevTools for a better development experience: https://fb.me/react-devtools
VM47 cypress_runner.js:114815 Download the React DevTools for a better development experience: https://fb.me/react-devtools
VM47 cypress_runner.js:68763 Slow network is detected. Fallback font will be used while loading: http://localhost:61036/__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.6.3
VM47 cypress_runner.js:163613 console.clear() was prevented due to 'Preserve log'
localhost/:13 GET http://localhost:8080/__/main.js net::ERR_ABORTED
Navigated to http://localhost:8080/__/
Navigated to http://localhost:61036/__/
VM57 cypress_runner.js:153927 Download the React DevTools for a better development experience: https://fb.me/react-devtools
VM57 cypress_runner.js:114815 Download the React DevTools for a better development experience: https://fb.me/react-devtools
VM57 cypress_runner.js:68763 Slow network is detected. Fallback font will be used while loading: http://localhost:61036/__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.6.3
VM57 cypress_runner.js:163613 console.clear() was prevented due to 'Preserve log'

Desired behavior:

Run a test and return fail/pass, see the Cypress UI. Tell me what I am doing wrong.

Steps to reproduce: (app code and test code)

Clone latest commit from: https://github.com/ethernal/react-boilerplate

run:
yarn install
npm run server
npm run cypress

Select smoketest_homepage_spec.js test. It will show the HTML file without JS loaded.

Versions

Cypress package version: 3.1.4
Cypress binary version: 3.1.4
Windows 10 1803 Enterprise
Browser: Version 64.0.3282.186 (Official Build) (64-bit)

@jennifer-shehane
Copy link
Member

Hey @ethernal, can you double check your Browser version and ensure it is version 64?

I am currently experiencing this issue on Chromium 72 & 73, but not Chromium 70.

Setting modifyObstructiveCode to false had no effect on fixing the issue.

This almost seems related to this issue where Cypress is loading a static html file.

This needs more investigation.

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this type: bug labels Jan 14, 2019
@ethernal
Copy link
Author

ethernal commented Jan 14, 2019

When running tests from first examples (testing true to be true and true to be false), this is my OS browser:
cypress-test-false-is-true-same-browser

Cypress Task Runner UI shows Chrome 64 as well (all settings are default, I have not modified the cypress.json):
cypress-runner-version

@ethernal
Copy link
Author

I have also checked with Chrome 71 - same behavior with enterprise version. No if there was a way to revert that change it would be great. @jennifer-shehane are you able to provide chrome enterprise installers for version that works for you so I can check if this is configuration issue or Chrome issue?

@ethernal
Copy link
Author

When testing with Electron (builtin setup) then everything works. I just now tested with Chrome 71 on my desktop PC and it seems there are settings in Chrome managed via GPO that make Cypress fail.

So this is an issue with my configuration of Chrome as Electron will use engine that is not managed by admins. Is there a way to check which setting(s) is/are affecting Cypress or is there a way to use some custom installation of Chrome (portable?) and point Cypress to it ex. npm/yarn dependency?

@flotwig flotwig self-assigned this Jan 22, 2019
@flotwig
Copy link
Contributor

flotwig commented Jan 22, 2019

@ethernal I'm glad you commented with an update, I was having trouble reproducing this behavior under Chrome 71. If it's localized to your group policy then I can press pause on that.

Re: installing other versions of Chrome - You can install Chromium (the open source side of Chrome), and we support that. You can also install Chrome Canary, which is the nightly build of Chrome. Both of these will be auto-detected next time you run Cypress. Will these work to evade your group policy?

Here's some docs about that: https://docs.cypress.io/guides/core-concepts/launching-browsers.html#Browsers

@ethernal
Copy link
Author

ethernal commented Jan 23, 2019

@flotwig I read that documentation and Installed both Chrome Beta and Chromium. Neither is picked up by Cypress also I would love to see in Documentation side by side information on how to use cypress.json ex. to run chrome the docs say:

cypress run --browser chrome

What I am missing is that in cypress.json I should put

{
browser: "chrome" // or electron or... chromium?
}

Also the API docs suggest there are only 2 settings: "chrome" and "electron" so how do I specify chromium when Cypress did not see it installed (got one from: https://chromium.woolyss.com/) Also a link to any supported Chromium version would be great as it's a pain to find a stable version.

PS. can we use cypress.config.js as well or only json?

@flotwig
Copy link
Contributor

flotwig commented Jan 23, 2019

To run Chromium, the command is

cypress run --browser chromium

cypress.json does not accept a browser configuration variable.

Only cypress.json works; however, you can modify the config from your cypress/plugins/index.js file.

If you can't get Chromium working, for now, there is not a way to explicitly pass the path of your browser to Cypress like proposed in #1026. Does the Electron browser work for your needs in the mean time?

@ethernal
Copy link
Author

Yes it does. I did check earlier and that config changed nothing as you said. Although first change made the internal browser use Electron so that was misleading. I think we can close the issue. PS is there a way to check what settings make Chrome act so strange? It would be useful for troubleshooting I believe.

@flotwig
Copy link
Contributor

flotwig commented Jan 24, 2019

@ethernal You can visit chrome://policy in Chrome and click "export to JSON", then share that file with us here. Thanks for offering, that will be helpful for us to debug issues for enterprise users down the road.

@ethernal
Copy link
Author

ethernal commented Jan 26, 2019

I removed the domain names and internal addresses but it is all. No real data/options are removed::

{
   "chromePolicies": {
      "BackgroundModeEnabled": {
         "level": "mandatory",
         "scope": "machine",
         "source": "sourcePlatform",
         "value": false
      },
      "HomepageLocation": {
         "level": "mandatory",
         "scope": "machine",
         "source": "sourcePlatform",
         "value": "https://internalNetwork.domain.com/"
      },
      "JavaScriptAllowedForUrls": {
         "level": "mandatory",
         "scope": "machine",
         "source": "sourcePlatform",
         "value": [ "*.domain.com ", "*.internalDomain.internal " ]
      },
      "ProxySettings": {
         "level": "mandatory",
         "scope": "machine",
         "source": "sourcePlatform",
         "value": {
            "ProxyMode": "system"
         }
      },
      "SyncDisabled": {
         "level": "mandatory",
         "scope": "machine",
         "source": "sourcePlatform",
         "value": true
      }
   },
   "extensionPolicies": {
      "ghbmnnjooekpmoecnnnilnnbdlolhkhi": {

      }
   }
}

@flotwig
Copy link
Contributor

flotwig commented Feb 20, 2019

Been looking in to the proxy problems, and it looks your ProxyMode is set to system by an administrator. This forces Chrome to use the system proxy for all requests instead of using Cypress's special testing proxy, which is what is causing the behavior described in this issue. It's hard to fix this issue from our end without resorting to hacky workarounds that feed Chrome fake registry data. Closing for now as a duplicate of #1253

@flotwig flotwig closed this as completed Feb 20, 2019
@flotwig flotwig added type: duplicate This issue or pull request already exists and removed stage: needs investigating Someone from Cypress needs to look at this labels Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: chrome type: bug type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants