-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
html base target _top lets cypress loose control #1364
Comments
We could rewrite this in the proxy layer sure - but you also have access to the DOM elements and could manually switch the attribute before you click the |
good point. I already made a cy command: Cypress.Commands.add("fix_base", () => {
cy.window().then((win) => {
win.document.querySelector('base').setAttribute('target', '_self')
})
}) but If I want to build Integration / E2E tests, which requires more clicks per testcase |
There is a much easier way documented here: https://on.cypress.io/catalog-of-events Just listen to the |
the thing is, that this code does not work: cy.on('window:load', (win) => {
win.document.querySelector('base').setAttribute('target', '_self')
}) the error I am getting is:
what sounds kind of logic, cause the page hasn't loaded yet. |
Are you rendering async? Another option would be to use
|
Also now that I think about it - inside of Cypress.on('window:load', () => {
cy.get('base').invoke('attr', 'target', '_self')
}) That will actually use Cypress to find the element (and retry automatically until it does) and then modify it. Those commands will show up enqueued in the command log which will be much more obvious. |
sorry, that won't work: (thanx for your time, by the way!) |
Duplicate of #3121 |
when you have in your html-head, cypress will loose control of the browser & tests. Cypress will show the whoops page when an is clicked. I would expect cypress somehow to overwrite the _top.
here is the showcase of whats going wrong:
https://github.com/joelgrimberg/cypress_base_issue
The text was updated successfully, but these errors were encountered: