cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.04k stars 3.19k forks source link

Cypress test runner redirects to __ suddenly #1064

Closed paulpruteanu closed 6 years ago

paulpruteanu commented 6 years ago

Is this a Feature or Bug?

Bug

Current behavior:

I run a test that opens a page and it randomly redirects from //#my/path/to/test.js to //

Desired behavior:

To have my test continue with its journey

How to reproduce:

Quite hard, it runs an URL routed internal looking like my-resource.test.group as nameserver UPDATE: When I reach to a stage when by clicking on a button, I submit a POST form, that redirects me to a page, which redirects to another one, which finally redirects to the last one (cypress reaches here successfully), then I see this network request in cypress Chrome dev tools: Request headers: GET /last/redirect/page/ HTTP/1.1 Host: my-resource.test.group Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8 Referer: https://my-resource.test.group/last/redirect/page/ Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9 Cookie: my-cookie; __cypress.unload=true

Response headers: HTTP/1.1 302 Found Location: /__/ Vary: Accept, Accept-Encoding Content-Type: text/html; charset=utf-8 Content-Length: 52 Date: Wed, 13 Dec 2017 16:30:47 GMT Connection: keep-alive

Test code:

cy.visit('https://my-resource.test.group')

Additional Info (images, stack traces, etc)

Wed, 13 Dec 2017 14:02:06 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers queuing timer id 86 after 30000 ms
Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers child received timer id 86
Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers clearing timer id 82 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '82': { args: [], ms: 30000, cb: [Function] }, '83': { args: [], ms: 30000, cb: [Function] }, '84': { args: [], ms: 30000, cb: [Function] },
'85': { args: [], ms: 30000, cb: [Function] }, '86': { args: [], ms: 30000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers clearing timer id 83 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '83': { args: [], ms: 30000, cb: [Function] }, '84': { args: [], ms: 30000, cb: [Function] }, '85': { args: [], ms: 30000, cb: [Function] },
'86': { args: [], ms: 30000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers clearing timer id 84 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '84': { args: [], ms: 30000, cb: [Function] }, '85': { args: [], ms: 30000, cb: [Function] }, '86': { args: [], ms: 30000, cb: [Function] } }

Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers clearing timer id 85 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '85': { args: [], ms: 30000, cb: [Function] }, '86': { args: [], ms: 30000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:06 GMT cypress:server:timers clearing timer id 86 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '86': { args: [], ms: 30000, cb: [Function] } }
←[0mGET /my/resource/style/global4-min171207.css ←[32m200 ←[0m310.511 ms - -←[0m
←[0mGET /my/resource/style/global2-min171207.css ←[32m200 ←[0m344.248 ms - -←[0m
←[0mGET /personal/static/desktop/scriptsnippet.jspf ←[32m200 ←[0m338.899 ms - -←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 87 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 87
←[0mGET /my/resource/style/global3-min171207.css ←[32m200 ←[0m343.766 ms - -←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 88 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 88
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 89 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 89
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 90 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 90
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 88 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '87': { args: [], ms: 30000, cb: [Function] }, '88': { args: [], ms: 30000, cb: [Function] }, '89': { args: [], ms: 30000, cb: [Function] },
'90': { args: [], ms: 30000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 87 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '87': { args: [], ms: 30000, cb: [Function] }, '89': { args: [], ms: 30000, cb: [Function] }, '90': { args: [], ms: 30000, cb: [Function] } }

Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 89 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '89': { args: [], ms: 30000, cb: [Function] }, '90': { args: [], ms: 30000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 90 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '90': { args: [], ms: 30000, cb: [Function] } }
←[0mGET /my/resource/style/global1-min171207.css ←[32m200 ←[0m556.545 ms - -←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 91 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 91
←[0mGET /my/resource/assets/lib/jquery-min171207.js ←[32m200 ←[0m511.813 ms - -←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 91 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '91': { args: [], ms: 30000, cb: [Function] } }
←[0mGET /my/resource/logo-1431368880.png ←[32m200 ←[0m365.740 ms - -←[0m
←[0mGET /my/resource/script/custom-min171207.js ←[32m200 ←[0m392.222 ms - -←[0m
←[0mGET /my/resource/assets/lib/ress/js/mca-header-footer-min171207.js ←[32m200 ←[0m415.897 ms - -←[0m
←[0mGET /my/resource/style/print/print_base-min171207.css ←[32m200 ←[0m321.749 ms - -←[0m
←[0mGET /my/resource/assets/lib/global-min171207.js ←[32m200 ←[0m517.176 ms - -←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 92 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 92
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 80 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '80
': { args: [], ms: 85000, cb: [Function] }, '92': { args: [], ms: 30000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 93 after 85000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 93
←[0mGET /colleague/a/find_cust/ ←[36m302 ←[0m2.044 ms - 52←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:routes Serving Cypress front-end by requested URL: /__/
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:server Getting remote state: { props: { port: '443', tld: 'group', domain: 'test' }, origin: 'https://my-resource
.test.group', strategy: 'http', visiting: false, domainName: 'test.group', fileServer: null }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 92 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '92
': { args: [], ms: 30000, cb: [Function] }, '93': { args: [], ms: 85000, cb: [Function] } }
←[0mGET /__/ ←[32m200 ←[0m10.617 ms - -←[0m
←[0mGET /my/resource/style/has_js.css ←[32m- ←[0m- ms - -←[0m
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 93 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '93
': { args: [], ms: 85000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 94 after 85000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 94
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers queuing timer id 95 after 30000 ms
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers child received timer id 95
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 95 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '94
': { args: [], ms: 85000, cb: [Function] }, '95': { args: [], ms: 30000, cb: [Function: bound cleanupWebsocketResources] } }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 60 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '60': { args: [], ms: 85000, cb: [Function] }, '94
': { args: [], ms: 85000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:07 GMT cypress:server:timers clearing timer id 60 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '94': { args: [], ms: 85000, cb: [Function] } }
←[0mGET /__cypress/runner/cypress_runner.js ←[36m304 ←[0m2.201 ms - -←[0m
←[0mGET /__cypress/runner/cypress_runner.css ←[32m200 ←[0m51.092 ms - -←[0m
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:server Got CONNECT request from my-resource.test.group:443
Wed, 13 Dec 2017 14:02:08 GMT cypress:https-proxy Writing socket connection headers for URL: my-resource.test.group:443
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:cors Parsed URL { port: '443', tld: 'group', domain: 'test' }
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:server HTTPS request does match URL: https://my-resource.test.group:443 with props: { port: '443', tld: 'group',
domain: 'test' }
Wed, 13 Dec 2017 14:02:08 GMT cypress:https-proxy Not making direct connection to my-resource.test.group:443
Wed, 13 Dec 2017 14:02:08 GMT cypress:https-proxy Making intercepted connection to 55224
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:server Got UPGRADE request from /__socket.io/?EIO=3&transport=websocket
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers queuing timer id 96 after 85000 ms
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child received timer id 96
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:socket socket connected
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers clearing timer id 96 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '94': { args: [], ms: 85000, cb: [Function] }, '96
': { args: [], ms: 85000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers queuing timer id 97 after 85000 ms
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child received timer id 97
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers clearing timer id 97 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '94': { args: [], ms: 85000, cb: [Function] }, '97
': { args: [], ms: 85000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers queuing timer id 98 after 85000 ms
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child received timer id 98
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers queuing timer id 99 after 1000 ms
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child received timer id 99
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers clearing timer id 94 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '94': { args: [], ms: 85000, cb: [Function] }, '98
': { args: [], ms: 85000, cb: [Function] }, '99': { args: [], ms: 1000, cb: [Function: timeoutTimeout] } }
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers queuing timer id 100 after 85000 ms
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers clearing timer id 99 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '98': { args: [], ms: 85000, cb: [Function] }, '99
': { args: [], ms: 1000, cb: [Function: timeoutTimeout] }, '100': { args: [], ms: 85000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child received timer id 100
←[0mGET /__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.7.0 ←[36m304 ←[0m1.125 ms - -←[0m
←[0mGET /__cypress/runner/no-spec-instructions.png ←[32m200 ←[0m5.548 ms - 46495←[0m
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child sending timer id 7
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers clearing timer id 7 from queue { '7': { args: [], ms: 2500, cb: [Function: cb] }, '98': { args: [], ms: 85000, cb: [Function] }, '100
': { args: [], ms: 85000, cb: [Function] } }
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers queuing timer id 7 after 2500 ms
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:files looking for test files in the integration folder C:\dev\project\tests\integration\scenarios
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:timers child received timer id 7
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:files found test file C:/dev/project/tests/integration/scenarios/dev.js
Wed, 13 Dec 2017 14:02:08 GMT cypress:server:files found test file C:/dev/project/tests/integration/scenarios/foo.js

Look for

Wed, 13 Dec 2017 14:02:07 GMT cypress:server:routes Serving Cypress front-end by requested URL: /__/
jennifer-shehane commented 6 years ago

Curious if you have tried updating to a newer version of Cypress? If not, why do you need 1.0.3?

paulpruteanu commented 6 years ago

I'm working behind a corporate firewall, and it might take some time until I'll get the latest binary in.

brian-mann commented 6 years ago

I am extremely confident this is due to security mechanisms in the app you're visiting preventing Cypress from working. You'll need to disable those or figure out where the checks are and use Cypress to disable them.

There are lots of issues that explain this in more detail:

paulpruteanu commented 6 years ago

I dig deeper comparing the manual browse and cypress, and it seems like the cypress iframe might cause the issue. There is, indeed, a check in the code that does

if (top !== self) {
    top.location.href = self.location.href;
}

which, re-triggers the request, which might redirect to __ UPDATE:

Cypress.on('window:before:load', (win) => {
      Object.defineProperty(win, 'self', {
        get: () => {
          return window.top
        }
      })
    })

did the trick, many thanks!

brian-mann commented 6 years ago

Yup. There is an easy fix for that in the links I posted.

joelgrimberg commented 6 years ago

I am building an E2E test in which I use a button / submit to go to a second page. the submit triggers a redirect. The code as shown above does not work for redirects behind buttons; only for cy.visit (as it looks)

jennifer-shehane commented 6 years ago

Some updates to frame-busting changes we're making can be read here: #886

brian-mann commented 6 years ago

Yup this is fixed by https://github.com/cypress-io/cypress/pull/1295

brian-mann commented 6 years ago

Released in 2.0.0.

naraharun commented 6 months ago

Still happening the full screen even though tried the above solutions.

jennifer-shehane commented 6 months ago

@naraharun Please open a new issue with a fully reproducible example.