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?
Asked
Active
Viewed 1.3k times
2 Answers
12
Easiest way I could find:
Command: runScript
Value:
javascript{this.browserbot.getCurrentWindow().document.getElementById('hiddenElementId').value='TheValue'}

Sixty4Bit
- 12,852
- 13
- 48
- 62
-
3+1 good answer, even easier with a js library (if the page under test uses one), e.g. jquery:`$('#hiddenEl').val('foo')` – chim Jan 20 '12 at 08:55
-
I couldn't get the jquery one to work. jQuery is in the page. Can you post the entire string you have in your Selenium runScript value? – Matthew Lock Sep 20 '12 at 07:01
-
You might want to simply put it within the appropriate domready functionality, e.g. `$(function(){// on domready $('#hiddenEl').val('foo');});` – Kzqai Oct 04 '12 at 00:07
-
A bit late, but how do I achieve this with java? TIA!! – jackrabb1t Feb 02 '17 at 13:33
3
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)

mark
- 344
- 3
- 8