Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cypress – how to get element by last word in it

If this is the ID -> div id="random_is_good"

I want to get this element but only to catch "_is_good"

how can i do it ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Or I only have the start and end -> "random_ _good"

>Solution :

Symbol * – Match elements that with partial text match

cy.get('[div*="_is_good"]')

Symbol ^ – Match elements that starts with given value

div[id^="random_"]

Symbol $ – Match elements that ends with given value

div[id$="_good"]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading