How to check if an element exists on the webpage using Cypress #29389
sravanthi1047
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
I am beginner in Cypress. Can anyone please help me by answering my question, it may be simple to u guys but not for me. Please help.
My requirement is such that based on the existence of an UI element on the application, for eg, if the searched user yields results on the users grid , the test should go and update its values otherwise it should go and create a new user with the desired details.
To perform this search I have tried using the following commands, but nothing is working out. Moreover, I am expecting the error should not be thrown when the searched element is "not" found on the application, but Cypress is observed to be raising the error.
var len=cy.get('#Id1').get("table").filter("#Id2").length

Error:
var len=cy.get('#Id1 table").find("#Id2").length

Error:
Can anyone pl let me know how can i perform this simple verification of UI element presence using Cypress, without having any error being raised in case that optional UI element misses on the application. Any help is greatly appreciated. Thanks
Beta Was this translation helpful? Give feedback.
All reactions