Q:

Does watir-webdriver have a "wildcard tag"?

You know how you can search a page's source like this:
browser.div(:text => /foo/)

How can you do something like this:
browser.wildcard(:text => /foo/)

I'm looking for this functionality because I visit page 1 which has
<tag1>foo</tag1>

but page 2 has
<tag2>foo</tag2>

and it is a certainty that foo occurs nowhere else in the page for both pages.

A:

Element will find any element that matches regardless of tag name:
browser.element(text: /foo/)
Justin makes a great point in the comments. Pairing #element with a regex value will result in returning the html element. 
If you want the last tag that references it (note that this is probably a prohibitively non-performant option):
browser.element(text: /foo/, index: -1)
If there aren't any issues with nested spans, this would be a slightly faster option:
b.element(text: /foo/, tag_name: /span|td/)
In general, it is much much better to avoid using regular expression matchers when you don't *have to use them.

