How to print array values using selenium IDE

3,325 views
Skip to first unread message

unni

unread,
Jun 26, 2012, 8:00:57 AM6/26/12
to seleniu...@googlegroups.com
 
<tr>
   
<td>echo</td>
   
<td>${ans}</td>
   
<td></td>
</tr>
<tr>
   
<td>store</td>
   
<td>javascript{storedVars['ans'].split('/');}</td>
   
<td>final</td>
</tr>
<tr>
   
<td>echo</td>
   
<td>${final}</td>
   
<td></td>
</tr>
<tr>
   
<td>echo</td>
   
<td>javascript{storedVars['final'][0];}</td>
   
<td></td>
</tr>

Results:
  • [info] Executing: |echo | ${ans} | |
  • [info] echo: 1367-2630/14/1/013014
  • [info] Executing: |store | javascript{storedVars['ans'].split('/');} | final |
  • [info] Executing: |echo | ${final} | |
  • [info] echo: 1367-2630,14,1,013014
  • [info] Executing: |echo | javascript{storedVars['final'][0];} | |
  • [info] echo: 1 -------- instead of this i want to print the first value (1367-2630) .. likewise i want to print 2nd array- 14, then 1 and then 13014.

how do i achieve?


unni

unread,
Jun 29, 2012, 6:09:14 AM6/29/12
to seleniu...@googlegroups.com
how do i get  value?

Mike Riley

unread,
Jun 29, 2012, 11:42:47 AM6/29/12
to seleniu...@googlegroups.com
There is a storeValue command in the IDE, as well as an assertValue and verifyValue, and probably some others.

The best way to find things is to make some command for the web element you want to interact with, select that line, and simply explore what the various command are that are available by going through the list.

Mike

kiisu

unread,
Jul 2, 2012, 1:39:56 PM7/2/12
to seleniu...@googlegroups.com
<tr>
<td>store</td>
<td>1367-2630/14/1/013014</td>
<td>ans</td>
</tr>
<tr>
<td>echo</td>
<td>${ans}</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>storedVars['ans'].split('/');</td>
<td>final</td>
</tr>
<tr>
<td>echo</td>
<td>${final}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>for(i=0; i&lt; storedVars['final'].length;i++) {this.doEcho(storedVars['final'][i]);}</td>
<td></td>
</tr>

-kiisu

kiisu

unread,
Jul 3, 2012, 11:58:26 AM7/3/12
to seleniu...@googlegroups.com
I'm not sure how this is related to the original message, but it looks like you meant the first "echo" to be a "store".

<tr>
<td>store</td>
<td>WALK-IN TAB IS CLICKED</td>
<td>wk</td>
</tr>
<tr>
<td>echo</td>
<td>${wk}</td>
<td></td>
</tr>

that seems rather redundant though, unless you really need to repeat ${wk} in your script.

-kiisu

On Tuesday, July 3, 2012 1:59:35 AM UTC-7, Lucan wrote:
<tr>
    <td>open</td>
    <td>/dashboard/Index</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>css=#dtoolCustomer &gt; span.ui-button-text</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>//div[@id='dashbuttonbar']/a/span</td>

    <td></td>
</tr>
<tr>
    <td>echo</td>
    <td>WALK-IN TAB IS CLICKED</td>
    <td>wk</td>

</tr>
<tr>
    <td>echo</td>
    <td>${wk}</td>
    <td></td>
</tr>

here what am doing is try to say that the walk-in tab is clicked.. but in the output it doesn't show the data added to the echo and also no errors.. help me to get my desired out put...

unni

unread,
Jul 16, 2012, 5:26:36 AM7/16/12
to seleniu...@googlegroups.com
Thanks for reply.. but it throws

  • [info] Executing: |getEval | for(i=0; i&lt; storedVars['final'].length;i++) {this.doEcho(storedVars['final'][i]);} | |
  • [info] script is: for(i=0; i&lt; storedVars['final'].length;i++) {this.doEcho(storedVars['final'][i]);}
  • [error] Threw an exception: missing ) after for-loop control

kiisu

unread,
Jul 16, 2012, 12:08:33 PM7/16/12
to seleniu...@googlegroups.com
sorry pasting it in changed the "<" to "&lt;" which obviously breaks the code.
swap "&lt;" to a "<" and it should work.

-k

unni

unread,
Jul 18, 2012, 8:07:19 AM7/18/12
to seleniu...@googlegroups.com
result:

    • [info] Executing: |echo | ${final} | |
    • [info] echo: 1367-2630,14,1,013014
    • [info] Executing: |getEval | for(i=0; i<storedVars['final'].length;i++) {this.doEcho(storedVars['final'][i]);} | |
    • [info] script is: for(i=0; i<storedVars['final'].length;i++) {this.doEcho(storedVars['final'][i]);}
    • [info] echo: 1
    • [info] echo: 3
    • [info] echo: 6
    • [info] echo: 7
    • [info] echo: -
    • [info] echo: 2
    • [info] echo: 6
    • [info] echo: 3
    • [info] echo: 0
    • [info] echo: ,
    • [info] echo: 1
    • [info] echo: 4
    • [info] echo: ,
    • [info] echo: 1
    • [info] echo: ,
    • [info] echo: 0
    • [info] echo: 1
    • [info] echo: 3
    • [info] echo: 0
    • [info] echo: 1
    • [info] echo: 4
    it prints one char by char.. i expect arrray by array as
    [info] echo: 1367-2630
    [info] echo: 14
    [info] echo: 1
    [info] echo: 013014

    kiisu

    unread,
    Jul 18, 2012, 12:32:41 PM7/18/12
    to seleniu...@googlegroups.com
    looks like ${final} isn't being stored as an array.  Did you change the code before that?

    -kiisu

    unni

    unread,
    Jul 19, 2012, 2:35:52 AM7/19/12
    to seleniu...@googlegroups.com
    no.. its the same code as in my first post.. I split the "ans" and stored it into "final" and u can see the print.
    after that i used your code and posted the result..

    kiisu

    unread,
    Jul 19, 2012, 5:53:01 PM7/19/12
    to seleniu...@googlegroups.com
    Instead of using store use storeEval to make sure the "final" variable is an array.  

    <td>storeEval</td>
    <td>storedVars['ans'].split('/');</td>
    <td>final</td>



    Robert Lake

    unread,
    Oct 17, 2013, 10:10:21 PM10/17/13
    to seleniu...@googlegroups.com
    Probably you will get all question's answers related to selenium IDE at this link. http://software-testing-tutorials-automation.blogspot.in/search/label/selenium%20ide


    On Friday, June 29, 2012 3:09:14 AM UTC-7, unni wrote:
    Reply all
    Reply to author
    Forward
    0 new messages