How do regular expressions work in selenium? How do regular expressions work in selenium? selenium selenium

How do regular expressions work in selenium?


The solution is to use the JavaScript replace() function with storeEval:

| storeAttribute | //pathToMyElement@id                                   | elementID || storeEval      | '${elementID}'.replace("element-", "")                 | myID      |

Now if I echo myID I get just the ID:

| echo | ${myID} | 12345 |


/element-(\d+)/i

That's a regular expression that would capture the numbers after the dash.


Something like this might work:

| storeAttribute | fn:replace(//pathToMyElement@id,"^element-","") | myId |

To do regex requires XPath 2.0 - not sure which version Selenium implements.