I am running a browser test with splinter and have a page with a large table. I want to locate all <tr>
elements that contain a <td>
with some nicely-formatted date in their text, like the one highlighted here:
It's easy to find the rows with specific text, e.g., via:
browser.find_by_xpath('//tr[.//td[contains(text(), "September")]]')
So then I tried something like the suggestions here to find text() with the general date pattern (help with simplifying my regex is welcome, too):
exp = '[A-Z][a-z]+\\s[1-9]{1,2},\\s[0-9]{4}'
browser.find_by_xpath('//tr[.//td[matches(text(), "{0}")]]'.format(exp))
This doesn't work (and I did verify that the regex works in isolation). Nor does:
browser.find_by_xpath('//tr[.//td[matches(., "{0}")]]'.format(exp))
Provided my browser allows XPath 2.0, how can I find the elements correctly?