Watir - 使用部分文本查找元素

Dhr*_*tel 2 ruby testing automation automated-tests watir-webdriver

有没有办法通过它包含的文本找到元素?

鉴于:

<div>foobar</div>

browser.div(text: contains('foo')).present?   
# => true
Run Code Online (Sandbox Code Playgroud)

tit*_*ner 7

是! 只需使用正则表达式:

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