From f82f5a48af0107174cf04d7a1cf9cd1f8e4fd04a Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Tue, 22 Apr 2025 14:39:49 +0200 Subject: [PATCH] Fix "cy.visit() succeeded, but commands are timing out" error example --- docs/app/references/error-messages.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/app/references/error-messages.mdx b/docs/app/references/error-messages.mdx index 0f51799c1a..f2615a4bfd 100644 --- a/docs/app/references/error-messages.mdx +++ b/docs/app/references/error-messages.mdx @@ -498,18 +498,18 @@ as-is: ```javascript it('navigates to docs.cypress.io', () => { cy.visit('http://localhost:3000') - cy.visit('https://docs.cypress.io') // visit a different superdomain + cy.visit('https://docs.cypress.io') // visit a different domain }) ``` -However, when the newly visited URL is not considered the same superdomain, the +However, when the newly visited URL is not considered the same domain, the [`cy.origin()`](/api/commands/origin) command **must** be used to interact with the newly visited domain. The following test is incorrect: ```javascript it('navigates to docs.cypress.io and runs additional commands', () => { cy.visit('http://localhost:3000') - cy.visit('https://docs.cypress.io') // visit a different superdomain + cy.visit('https://docs.cypress.io') // visit a different domain cy.get('h1').should('contain', 'Why Cypress?') // fails }) ``` @@ -525,10 +525,10 @@ In order to fix this, our `cy.get()` command **must** be wrapped with the [`cy.origin()`](/api/commands/origin) command, like so: ```javascript -it('navigates to example.cypress.io and runs additional commands', () => { +it('navigates to docs.cypress.io and runs additional commands', () => { cy.visit('http://localhost:3000') - cy.visit('https://example.cypress.io') // visit a different superdomain - cy.origin('https://example.cypress.io', () => { + cy.visit('https://docs.cypress.io') // visit a different domain + cy.origin('https://docs.cypress.io', () => { cy.get('h1').should('contain', 'Why Cypress?') // now succeeds! }) })