uncledru
uncledru

Reputation: 143

Watir - Find elements using partial text

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

Answers (1)

titusfortner
titusfortner

Reputation: 4194

Yes! Just use a regular expression:

browser.div(text: /foo/).present?

Upvotes: 10

Related Questions