cy.contains And Regular Expressions Examples @gleb
cy.contains And Regular Expressions Examples  @gleb
Uploaded June 2023 | Updated September 2026, 1 week ago
You can use the versatile cy.contains command to find elements on the page by text. You can also:
- ignore the text case using "matchCase: false" option
- use regular expressions
- construct a regular expression if the string to find comes from a variable
For example:
const value = 'hello'
const regex = new RegExp('^' + value, 'i')
cy.contains('#greeting', regex)
Find this and many more examples at glebbahmutov.com/cypress-examples
cy.contains And Regular Expressions ExamplesCypress cy.filter Command Attribute ExamplesSkip Dependent Cypress Tests On FailureCypress vs Playwright Course AnnouncementCheck Console Logscypress-await Sync Mode ExampleEmpty List Items Should Not ExistDispatch Custom HTML Events From Cypress TestsZero Or Three Elements After Loading The DataParse The Account Number ExplainedChai-each Plugin ExampleCypress Component Testing Vs RTL and MSW: The Missing Comparison Part
gleb bahmutov |

cy.contains And Regular Expressions Examples

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER