Tomas
Tomas

Reputation: 45

Finding elements: different syntax -> different results - Explanation needed

When I use: cy.get('b').contains('xdz') // find 1 element

but when I use: cy.get('b:contains("xdz")') // find 2 elements

Can someone explain me what is the difference?

Upvotes: -1

Views: 208

Answers (1)

Alapan Das
Alapan Das

Reputation: 18634

contains('xdz') is a cypress command which always yields only the first element containing the text. You can read more about it from this Github Thread.

:contains("xdz") is a Jquery command and it returns all elements containing the text. You can read more about it from the Jquery Docs.

Upvotes: 0

Related Questions