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.

Cypress is not able to verify the existence of newly attached element

See original GitHub issue

Current 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:

  1. Visit page
  2. Fill in the form
  3. Submit
  4. Wait for success XHR status
  5. Verify newly attached success toast.

cypressnotabletoseeelement0 cypressnotabletoseeelement

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:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
davidzambranacommented, Jan 28, 2019

@kapalkat in your case, if you change your

cy.get('#toast-container .toast-success', { timeout: 5000 }).should('contain', 'Parcel updated!')

to

cy.contains('.toast-success', 'Parcel updated!')

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.

4reactions
jennifer-shehanecommented, Nov 28, 2018

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?

Read more comments on GitHub >

github_iconTop 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 >

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