Home > Enterprise >  Cypress - how to get element by last word in it
Cypress - how to get element by last word in it

Time:06-22

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 ?

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

CodePudding user response:

Symbol * - Match elements that with partial text match

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

Symbol ^ - Match elements that starts with given value

cy.get('div[id^="random_"]')

Symbol $ - Match elements that ends with given value

cy.get('div[id$="_good"]')
  • Related