Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress on click, is there any method to wait until DOM is loaded? (without using wait())

I have a small problem in React project, when I want to use .click() from Cypress sometimes I have an error failed because this element is detached from the dom. The simple solution is to add wait() before each test to let the site render fully but it isn't the best solution for me. Is there any way to do it without using wait()?

like image 416
kamil kowalczyk Avatar asked Nov 19 '25 21:11

kamil kowalczyk


1 Answers

This is related to a known cypress issue that they promise to fix soon: https://github.com/cypress-io/cypress/issues/7306

Until that's solved you can either add .wait(), if it works for your scenario, or alternative try .click({force: true}). Either have downsides though.

like image 113
M Kowalski Avatar answered Nov 21 '25 13:11

M Kowalski