How To Avoid Element Detached From DOM Error

Поделиться
HTML-код
  • Опубликовано: 2 фев 2025

Комментарии • 21

  • @waelabboud
    @waelabboud 3 года назад +3

    This video illustrates the problem in an excellent way, and not only it shows a real solution, but even more than 1 solution! I did much research and most of the sites propose to use wait(1000) but I wasn't convinced with this solution since it could still fail if 1000 ms are not enough. Thank you so much! Keep up the good work.

  • @danr4826
    @danr4826 3 года назад +1

    I prefer using cy.intercept as you demonstrated. If i find the test is flaky, it usually fails attempting to interact with some DOM element or waiting for an action to finish, in that case I'll add a timeout for that action only and usually resolve the issue. I've yet to run my tests in CI so I'm anxiously waiting to see how the tests will behave there.
    Quality explanation, thanks 👍

  • @MuratKeremOzcan
    @MuratKeremOzcan 3 года назад

    Iterative assertions pattern!
    Thanks for taking the time to explain it.

  • @JimiSimpson
    @JimiSimpson 2 года назад +2

    Thank you for your efforts, this is awesome!

  • @antonywoods2556
    @antonywoods2556 3 года назад +3

    This is a good video, but I think many people (such as myself) encounter this problem with more complex SPAs. With a framework like React, and given the nature of async, elements may re-render at times that are completely disconnected from the actions the user/test runner is performing at the time.

    • @gleb
      @gleb  3 года назад

      I will wait for a reproducible example, since a) Cypress Dashboard is a complex React application with background data sync, etc that seems to be working quite well during tests b) Mercari US is a complex React application that seems to be working quite well during tests c) if everything else fails add cy.wait(xxx) plus enable test retries and move on

  • @BhagatSingh-mh4og
    @BhagatSingh-mh4og Год назад

    Q.1) Hi Gleb, I have 1 question So there is one button i.e 3 dots I am click on 3 dots(button) then It will open 4 options (edit,share,duplicate,delete) & then I am finally click on the 4th option(delete).-->this the flow
    So there is 3 dots button & 4th option button is there. but If I do not provide wait before 3 dots button & after 3 dots It will not click on the 4th option(delete) & by using cy.wait(); it is working but we can't use wait
    so my question is, Is there any method to replace the cy.wait();?

    • @gleb
      @gleb  Год назад +1

      I am sorry, I don't understand, RUclips comments are really hard to read this way. Could you ask your Cypress question at on.cypress.io/chat or on.cypress.io/discord or the specific repo via GH issues? It will be easier for your to provide code snippets, screenshots, etc to explain what you are trying to do. You could also help me answer Cypress-related questions faster by supporting me via GitHub sponsors github.com/sponsors/bahmutov, by buying my Cypress courses at cypress.tips/courses, or by inviting me to teach Cypress cypress.tips/workshops

  • @ppp.1334
    @ppp.1334 3 года назад

    THANKS,very usefull,
    i do have many problems with cypress automation.

  • @DavidHill1980
    @DavidHill1980 3 года назад

    Great video! Thanks, Gleb

  • @notthatkindofsam
    @notthatkindofsam 3 года назад

    Excellent video. Thank you

  • @diego_elohim
    @diego_elohim 2 года назад

    Thx, i got the solution!

  • @EwertonSilveiraAuckland
    @EwertonSilveiraAuckland 3 года назад

    Nice. Thanks

  • @balramshrivastav8214
    @balramshrivastav8214 3 года назад

    will you please tell how it works on puppeteer framework?
    Like i have selected an element with same classname and i want to click one by one but the problem is once it click on first link it will go to new page and Automate that page and come back again and then click on next link and automate that one also .
    On the second time i am getting an error like "Node is detached from document "
    Please help

    • @gleb
      @gleb  3 года назад

      I’m sorry I don’t understand your question. I’m showing Cypress and not Puppeteer

    • @balramshrivastav8214
      @balramshrivastav8214 3 года назад

      @@gleb i mean suppose if u have 5 matching element link and u have to click one by one . So i am clicking on 1st link and it will render to that page and close that page and click on the 2nd link and so on when at the second time looping the puppeteer says that "node is detached from document".

    • @balramshrivastav8214
      @balramshrivastav8214 3 года назад

      @@gleb i am just asking if u help me with puppeteer because i faced the same issue in puppeteer. So if u know about puppeteer then please let me know it would be helpful for me. Thanks in advance

    • @gleb
      @gleb  3 года назад

      @@balramshrivastav8214 can you make a public repo showing what you mean a f the test that gets an error?

    • @gleb
      @gleb  3 года назад

      @@balramshrivastav8214 unfortunately I don’t use puppeteer

  • @barscanates5573
    @barscanates5573 2 года назад +1

    Lots of angry comments :D