Skip to content
Advertisement

Cypress: if element exist then do something

I am having a problem with if element exist then do something. As an example:

JavaScript

the problem here is that cypress aborts the test if the button doesn’t exist but that’s exactly when cypress shouldn’t abort, it should do nothing and continue.

I need a solution for

JavaScript

Advertisement

Answer

One way you do it is to get the parent of the element in question, which you know would be displayed every time.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement