admin管理员组

文章数量:1425851

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

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

Share Improve this question edited Jun 17, 2014 at 4:35 Set Kyar Wa Lar 4,6446 gold badges33 silver badges57 bronze badges asked Jun 12, 2014 at 15:23 user3726499user3726499 814 silver badges13 bronze badges 1
  • here u go: stackoverflow./questions/7852287/… – Niek Vandael Commented Jun 12, 2014 at 15:28
Add a ment  | 

3 Answers 3

Reset to default 1

I resolve my problem thanks @sircapsalot

solution of my problem below:

storeEval | window.document.getElementsByName('myName')[0].value; | x 

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

Also, to store an attribute, you want the storeAttribute method bined 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.

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

本文标签: javascriptHow to get the value of input with Selenium IDEStack Overflow