0

How to retrieve the field value "value" from input via the Selenium IDE (this value is variable so I want to recover its value for reuse) My input field:

    <input class="myClass" type="text" value="15" name="myName">

When I tried the following code:

<tr>
    <td>store</td>
    <td>xpath("//input[@name='myName']").getAttribute(​"value");</td>
    <td>x</td>
</tr>
<tr>
    <td>echo</td>
    <td>${x}</td>
    <td></td>
</tr>

I have:

[info] echo: xpath("//input[@name='myName']").getAttribute("value");

instead of:

15

thanks for help

Set Kyar Wa Lar
  • 4,488
  • 4
  • 30
  • 57
user3726499
  • 81
  • 4
  • 13

3 Answers3

1

You are confusing javascript with the store method. getAttribute() is a javascript method.

Also, to store an attribute, you want the storeAttribute method combined with CSS:

<tr>
  <td>storeAttribute</td>
  <td>css=input[name='myName']@value</td>
  <td>x</td>
</tr>

If you are trying to execute javascript, then use storeEval.

ddavison
  • 28,221
  • 15
  • 85
  • 110
1

I resolve my problem thanks @sircapsalot

solution of my problem below:

storeEval | window.document.getElementsByName('myName')[0].value; | x 
user3726499
  • 81
  • 4
  • 13
1

storeValue works for input elements. Depending on what you need, that may be preferable to using storeEval.

David
  • 688
  • 7
  • 13