Reputation: 143
Is there a way to find an element by the text it contains?
Given:
<div>foobar</div>
browser.div(text: contains('foo')).present?
# => true
Upvotes: 2
Views: 4448
Reputation: 4194
Yes! Just use a regular expression:
browser.div(text: /foo/).present?
Upvotes: 10