Submits the given form on the page, optionally with the given form values.
Give the form fields values as an array.
Skipped fields will be filled by their values from the page.
You don't need to click the 'Submit' button afterwards.
This command itself triggers the request to form's action.
You can optionally specify what button's value to include
in the request with the last parameter as an alternative to
explicitly setting its value in the second parameter, as
button values are not otherwise included in the request.
Examples:
php
submitForm('#login', array('login' => 'davert', 'password' => '123456'));
or
$I->submitForm('#login', array('login' => 'davert', 'password' => '123456'), 'submitButtonName');
For example, given this sample "Sign Up" form:
html
You could write the following to submit it:
php
submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)), 'submitButton');
Note that "2" will be the submitted value for the "plan" field, as it is the selected option.
You can also emulate a JavaScript submission by not specifying any buttons in the third parameter to submitForm.
php
submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)));
public submitForm ( $selector, $params, $button = null ) | ||
$selector | ||
$params | ||
$button |