javascript - How to get the value of input with Selenium IDE - Stack Overflow

How to retrieve the field value "value" from input via the Selenium IDE (this value is variab

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745461695a4628736.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信