Cypress [Solved] | Sololearn: Learn to code for FREE!
0

Cypress [Solved]

I have an element that is created I believe with JS, I need to check if it exists without causing the cypress test to fail. Perhaps a custom command that returns true or false, something like cy.exists('[test-id=""something]') Any ideas?

16th Jun 2022, 2:09 PM
Charlie Crease-huggett
3 ответов
0
What do you mean by "believe"? If you are not sure of the language, you can check the end of the file name. if it ends in .js, it's a Javascript file. If not, please tell us.
16th Jun 2022, 2:28 PM
Justice
Justice - avatar
0
The element is not in the HTML initially, it appears after you press a button regardless if it is .js or .ts. I simply need to know if it exists or not with cypress e.g. before <html> <head> </head> <body> <input type="button">Some lable</input> </body> </html> after <html> <head> </head> <body> <input type="button">Some lable</input> <h1 test-id="hello">Some header</h1> </body> </html>
16th Jun 2022, 2:42 PM
Charlie Crease-huggett
0
There is a CY.get(). should (not.exist) which does what I require
16th Jun 2022, 9:01 PM
Charlie Crease-huggett