Set hidden input value in Selenium?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 15:15:21

问题


We have hidden input fields on our form and we need Selenium to set the value of those fields. What is the best way to set the value of hidden inputs via Selenium IDE?


回答1:


Easiest way I could find:

Command: runScript

Value:

javascript{this.browserbot.getCurrentWindow().document.getElementById('hiddenElementId').value='TheValue'}



回答2:


Late to the party...

When you use the IDE, you can add the command type with target id=yourID and value field value, this seems to work.

Copy the text below and paste it in the IDE to try it out

<tr>
    <td>type</td>
    <td>id=yourID</td>
    <td>field value</td>
</tr>

This seems to work for me (Selenium 2.9.1)



来源:https://stackoverflow.com/questions/8917612/set-hidden-input-value-in-selenium

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