I am using Java and Selenium. The HTML designers did not give really useful IDs. I need to access an element with the following:
<span id="gridcolumn-1040-textInnerEl"
I can use
//span[contains(@id, 'gridcolumn') and (contains(@id, 'textInnerEl'))]
for the xpath but this can get complicated (this is a simpler example). is there any way to use a regexp in an xpath such as the following:
//span[match(@id, '^gridcolumn-[%d]+-testInnerEl$']
to avoid multiple and contains(@id,...)
Try to use below XPath to match span by regex:
//span[matches(@id, '^gridcolumn-\d+-textInnerEl$')]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With