cypress: cy.visit is not working while navigating from `https` url to `http` url

Current behavior

cy.visit is not working while navigating from https url to http url. Here’s the sample code.

  cy.visit('https://www.bbc.co.uk/')
  cy.visit('http://europepmc.org/')
  cy.visit('https://www.bbc.co.uk/')
  cy.visit('http://europepmc.org/')

However the below code block works well because the very first url is http url

  cy.visit('http://europepmc.org/')
  cy.visit('https://www.bbc.co.uk/')
  cy.visit('http://europepmc.org/')
  cy.visit('https://www.bbc.co.uk/')

Desired behavior

It should able to redirect from https to http and http url to https

Test code to reproduce

cy.visit(‘https://www.bbc.co.uk/’) cy.visit(‘http://europepmc.org/’) cy.visit(‘https://www.bbc.co.uk/’) cy.visit(‘http://europepmc.org/’)

Cypress Version

12.10.0

Node version

v19.4.0

Operating System

macOS Monterey

Debug Logs

It just fails without any error message

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Hi @rakeshnambiar 👋, by default Cypress does not allow navigating between secure (https) and insecure (http) content. You can read more about it here. You could try putting the visits in cy.origin blocks:

    cy.origin('https://www.bbc.co.uk/', () => {
      cy.visit('/')
    })

    cy.origin('http://www.columbia.edu/~fdc/', () => {
      cy.visit('/sample.html')
    })

Thanks a lot, @MikeMcC399 for your help. I found with the below settings it’s working on Chrome. However, I will have the same issue on other browsers.

    chromeWebSecurity: false,
    experimentalModifyObstructiveThirdPartyCode: true,