Uploaded May 2026 | Updated September 2026, 1 week ago
This video shows selectors and commands in Cypress for picking elements with a certain HTML attribute present and absent. Find full recipe at glebbahmutov.com/cypress-examples
This video shows selectors and commands in Cypress for picking elements with a certain HTML attribute present and absent. Find full recipe at glebbahmutov.com/cypress-examples
![Custom Should Read Assertion From Cypress-map Plugin
This video shows a custom read assertion that checks the text of a single or multiple elements using strings or regular expressions:
cy.get(li).should(read, [
Write code,
Add tests,
/^Pay $d+ fine$/,
])
The assertion is part of my cypress-map plugin https://github.com/bahmutov/cypress-map and the full recipe I am showing in this video is at https://glebbahmutov.com/cypress-examples/recipes/should-read.html Custom Should Read Assertion From Cypress-map Plugin](https://i.ytimg.com/vi/AzJx-8VD6yI/mqdefault.jpg)
![Compare Text In An Element Against Several Possible Values Using oneOf Assertion
You can confirm an element has text that matches string A OR string B OR string C etc using the Chai oneOf assertion.
cy.get(#guest-name)
.invoke(text)
.should(be.oneOf, [Joe, Mary, Anna])
I prefer the above code to a regular expression. Find this example at https://glebbahmutov.com/cypress-examples Compare Text In An Element Against Several Possible Values Using oneOf Assertion](https://i.ytimg.com/vi/B6LqwUHXCcg/mqdefault.jpg)



![The Text Of Each Element Starts With The Given String
Lets confirm the search results when searching for text mi all start with this text (ignoring the case)
cy.get([name=state]).type(mi)
cy.get(#search-results li)
.should(exist)
.each(function ($li, k) {
const text = $li.text()
expect(text, `state ${k + 1}`).to.match(/^mi/i)
})
Find this example at https://glebbahmutov.com/cypress-examples/ The Text Of Each Element Starts With The Given String](https://i.ytimg.com/vi/BWuWf8mqe3k/mqdefault.jpg)




