Cypress is not able to verify the existence of newly attached element
See original GitHub issueCurrent behavior:
Cypress is not able to verify the existence of newly attached element.
Desired behavior:
Cypress is able to get a new DOM element.
Steps to reproduce:
My test looks like follow:
- Visit page
- Fill in the form
- Submit
- Wait for success XHR status
- Verify newly attached success toast.
The strange thing is that I have multiple forms on different pages and this works on 90% of them. My toast mechanism is EXACTLY the same on all of those pages so I really don’t know where the problem might be.
My XHR wait and then toast verification looks like follow:
cy.wait('@putProductsRateSingle').then((response) => {
expect(response.status).to.eq(200)
})
cy.get('#toast-container .toast-success', { timeout: 5000 }).should('contain', 'Parcel updated!')
Versions
3.0.2, MacOS, Chrome
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Cypress: Test if element does not exist - Stack Overflow
Here you have the result in Cypress: 0 matched elements ... Use .should('not.exist') to assert that an element does not exist in the...
Read more >Interacting with Elements - Cypress Documentation
Cypress checks whether an element you are making assertions on is still within the document of the application under test. When many applications...
Read more >Cypress basics: check if element exists - Filip Hric
In this article I'd like to take a look into how test if element exists, is visible and discuss some gotchas that might...
Read more >Assertions | Cypress examples (v9.7.0) - Gleb Bahmutov
In most cases, you do not need to explicitly check if the element exists - if the cy.get , cy.contains , etc. command...
Read more >8 Tricks I Learned From Cypress - Blog - ServMask
Since Cypress chains are asynchronous and they wait for each other, you can't store an element object into a variable. Instead, you need...
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
@kapalkat in your case, if you change your
to
do you still see the same issue?
In my case I’m verifying the toasts this way and I haven’t got any problem so far.
Unfortunately we’ll have to close this issue if no reproducible example is provided.
Can anyone provide a way to reproduce this - test code and/or html code that we can run on our machines to reproduce?