Extract part of a text with selenium IDE and put it into variable

拈花ヽ惹草 提交于 2019-12-19 11:46:10

问题


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>


来源:https://stackoverflow.com/questions/12861218/extract-part-of-a-text-with-selenium-ide-and-put-it-into-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!