Working with forms
The commands
Here is a list of commands that you can use to manipulate forms.
select_form | index of the form inside the page
This selects a form with the given index. The index is zero based. If no form is selected then all other following commands will fail.
set_textfield | name of textfield = text
Sets the text into the defined textfield. This also works for textarea fields.
set_option | name of the select box = value
Selects an option from a select box. The value must be one of the offered options.
set_checbox | name of the checkbox = true or false
Sets or unsets the defined checkbox.
submit_form | name of the button
Submit the form. You need to specify the name of the button because there might be more than just one submit button.
Example
This is the quite ugly HTML for our example. It covers the basic form elements that a form can use.
<body>
<form action="simple_test.html" method="GET">
Name:<input type="text" name="name"><br/>
Age:<input type="text" name="age"><br/>
<select name="mode">
<option value="1">Number 1</option>
<option value="2">Number 2</option>
<option value="3">Number 3</option>
<option value="4">Number 4</option>
</select>
<input type="checkbox" name="create" value="yes">
<br/>
<input type="submit" name="btn">
</form>
</body>
The testscript:
get_html | http://localhost:8181/form_test.html
select_form | 0
set_textfield | name = My NAME
set_textfield | age = 20
set_option | mode = Number 1
set_checbox | create = true
submit_form | btn