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.

DOM elements not found in origin block

See original GitHub issue

Current behavior

I am using cy.origin() to login with an external login provider. My case is very similar to this block (taken from this issue)

it('client redirects to login page', () => {
  cy.visit('https://mydomain.com/page') // server responds with a 2xx status code and client redirects to anotherdomain.com/login

  cy.origin('https://anotherdomain.com', () => {
    // no visit is needed here since we've already been redirected
    // cy.visit('https://mydomain.com/page')

    // perform login steps
    cy.get('#login-button').click() // clicking login button redirects back to mydomain.com
  })

  cy.get('#user').should('contain', 'username')
})

However, the cy.get in the origin block (in this example cy.get(‘#login-button’).click()) always fails to find the relevant DOM element. If I run this statement outside of the origin block, the element is found successfully but the test fails later as I need this origin.

Desired behavior

cy.get should also be able to find the relevant element in the cy.origin block.

Test code to reproduce

const innerLogin = (url: string, username: string, password: string) => {
    cy.visit(`/Account/LogOn?returnUrl=${encodeURIComponent(url)}`); //will redirect to the Auth0 login page
    const args = { username, password };
    cy.origin(
        "_[auth0 tenant url]_",
        { args },
        ({ username, password }): void => {
            cy.get("input[id=username]").click().type(username); //this element cannot be found if statement is run in origin block
            cy.get("button[type=submit]").click();
            cy.get("input[id=password]").click().type(password);
            cy.get("button[type=submit]").click();
        }
    );
};

Cypress Version

10.3.1, 10.4.0

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
AtofStrykercommented, Aug 17, 2022

We confirmed that https://github.com/cypress-io/cypress/pull/23297 should fix https://github.com/cypress-io/cypress/issues/22282. We can’t 💯 confirm since we do not have a concrete reproduction, but we feel confident that https://github.com/cypress-io/cypress/pull/23297 should resolve this issue.

1reaction
AtofStrykercommented, Aug 9, 2022

possibly related to #22282

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ability to remove DOM element instead of hiding? · Issue #2252
I know that it is canonical way to hide blocked elements. But sometimes it might be useful to actually remove DOM element.
Read more >
SecurityError: Blocked a frame with origin from accessing a ...
Any other answer I've found 1, 2, suggests that CORS/ Access-Control-Allow-Origin does not apply to iFrames, only to XHRs, Fonts, WebGL and ...
Read more >
How to Unblock a Web Page Element With uBlock Origin
To unblock any element, you need to open the uBlock Origin network logger, you can do this by clicking the uBlock Origin icon...
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 >
Phaser 3 API Documentation - Class: DOMElement
Takes a block of html from the HTML Cache, that has previously been preloaded into the game, and then creates a DOM Element...
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