DOM elements not found in origin block
See original GitHub issueCurrent 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:
- Created a year ago
- Comments:12 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
possibly related to #22282