Extract part of a text with selenium IDE and put i

2019-02-21 05:15发布

问题:

Could somebody tell me which command should I use to extract only the number(694575) from the text using Selenium Ide and to put it into a variable for further usage. Here is the div with the text:

<div class="loginBoxTitle">Edit Exhibition Centre - 694575, Exhibition Center1</div> 

May be commands like storeText,storeEval should work in this case ,but the part with the pasrsing is a mistery for me.

回答1:

I have solution, tricky 1

store  | Edit Exhibition Centre - 694575, Exhibition Center1 | string
store  | 1 | delimiter   
store  | javascript{storedVars['string'].split('- ')[storedVars['delimiter']]} | test
store  | 0 | delimiter1
store  | javascript{storedVars['test'].split(',')[storedVars['delimiter1']]} | output
echo   | ${output}

Try this 1, and let me know whether its working for you



回答2:

I Have an easy answer to this question. Try this code it will work.

<tr>
    <td>store</td>
    <td>Edit Exhibition Centre - 694575, Exhibition Center1</td>
    <td>string</td>
</tr>
<tr>
    <td>store</td>
    <td>javascript{storedVars['string'].substring(24)}</td>
    <td>string</td>
</tr>
<tr>
    <td>echo</td>
    <td>${string}</td>
    <td></td>
</tr>
<tr>
    <td>store</td>
    <td>javascript{storedVars['string'].substring(0,7)}</td>
    <td>string</td>
</tr>
<tr>
    <td>echo</td>
    <td>${string}</td>
    <td></td>
</tr>