2

I'm trying to assign a 6-digit sequence which lays in <pre>-node to a variable using "store" command with XPath and regex, but something is wrong with my approach.

Sample text from <pre>:

"OPERACIA, KOD PODTVERZDENIA 021477"

Command:

store(//table[@id='sms_table']/tbody/tr/td/pre[matches(text(),'[0-9]{6}')], foo)
1
  • The issue is that you're using the matches() function which is only available in XPath 2.0. Selenium-IDE uses XPath 1.0. Commented Sep 30, 2015 at 14:07

1 Answer 1

4

First thing to note, you should be using storeText, not store. Store will only record what you put in the target field, it won't look for the locator on the page. Also, the way you've done your regex ([0-9]{6}) won't give you what you'd need. That would look for a digit from 0-9 followed by 6 more digits.

I've recently had to do pretty much the same thing, the way I did it is separated this out into 2 commands, rather than trying to process it all in one go. so first command, store the full thing, second command, Regex to pull out the 6 digits. Like 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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.