Selenium: How to assign a variable part of a string using xpath and regex? -
i'm trying assign 6-digit sequence lays in <pre>
-node variable using "store" command xpath , regex, wrong approach.
sample text <pre>
:
"operacia, kod podtverzdenia 021477"
command:
store(//table[@id='sms_table']/tbody/tr/td/pre[matches(text(),'[0-9]{6}')], foo)
first thing note, should using storetext, not store. store record put in target field, won't locator on page. also, way you've done regex ([0-9]{6}) won't give you'd need. digit 0-9 followed 6 more digits.
i've had pretty same thing, way did separated out 2 commands, rather trying process in 1 go. first command, store full thing, second command, regex pull out 6 digits. below
<tr> <td>storetext</td> <td>//table[@id='sms_table']/tbody/tr/td/pre</td> <td>text</td> </tr> <tr> <td>storeeval</td> <td>storedvars['text'].match(/\d{6}/)</td> <td>digits</td> </tr>
Comments
Post a Comment