question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

visiting `https` then `http` of same subdomain fails saying you can only visit a single unique domain per test

See original GitHub issue

what_it_does:

CypressError: cy.visit() failed because you are attempting to visit a second unique domain.

You may only visit a single unique domain per test.

Different subdomains are okay, but unique domains are not.

The previous domain you visited was: 'https://www.sina.com.cn'

You're attempting to visit this new domain: 'http://sports.sina.com.cn'

http://sports.sina.com.cn is subdomain , but error. https://sports.sina.com.cn is ok.

Current behavior:

Desired behavior:

Steps to reproduce: (app code and test code)

Versions

Cypress: 3.8.0 │ Browser: Electron 78 (headless)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jan 8, 2020

Why

Ok, so, after discussing this with the team, this is actually expected behavior.

The rules for what we have been calling a ‘single unique domain per test’ are technically following the rules of Same Origin Policy as outlined here: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

Two URLs have the same origin if the protocol, port (if specified), and host are the same for both.

So visiting a different protocol (http to https) is not considered the same protocol.

The reason the http to https often works is because of the websites rerouting rules.

Next steps

  1. The error message we are throwing in the Test Runner is completely confusing in this regard. We only mention a ‘single domain’ policy and should be more specific to call out same origin policy. This error message should be updated.
  2. The documentation is just wrong. We talk about superdomain and then even mention http and https specifically being the same and following the rules. https://on.cypress.io/trade-offs#Same-origin I’ve created an issue to update this here: https://github.com/cypress-io/cypress-documentation/issues/2364
0reactions
cypress-bot[bot]commented, Feb 28, 2020

Released in 4.1.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v4.1.0, please open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress: How to visit a url of a different origin? - Stack Overflow
I did work for me but cypress fails the test after routing to the new url, throwing Cypress detected a cross origin error...
Read more >
Same-origin policy - Web security | MDN
The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a ......
Read more >
Web Security - Cypress Documentation
If you attempt to visit two different superdomains, the cy.origin command must be used to wrap Cypress commands of the second visited domain....
Read more >
Subdomain Visit Count - LeetCode
A count-paired domain is a domain that has one of the two formats "rep d1.d2.d3" or "rep d1.d2" where rep is the number...
Read more >
Fully Qualified Domain Name (FQDN): Complete Guide With ...
Does your site have a fully qualified domain name? Learn more about FQDNs and why they're important with our complete guide.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found