I am trying to use a software name Selenium (web rat) to simulate user interact with browser
For example , I trying to put the username field with name ‘john
However the ‘id’ of ‘username textbox’ is username_947232, username_8237
The format which username_[random numbers]
My syntax is following:
//*[contains(@id="username_(/\d+/)")]
but it’s not working , anyone have any idea??
Thank you for any suggestions!
Use:
Explanation:
This expression selects any element the string value of whose
idattribute starts with the string"username_"and the remainder of this string (after the starting"username_") is an integer.Here we use the fact that the following expression is true if and only if
$stringrepresents an integer:XSLT – based verification:
When this transformation is applied on this XML document:
the Xpath expression is evaluated and the selected node from this evaluation is copied to the output:
Do note: The other two answers to this question would select all 5
userelements from the above document — which, of course, is incorrect.