Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Response.submitForm( [params] )
Fill in and submit form found in HTML of response. By default it will look for the first form
tag in the HTML, but this can be overridden using the formSelector
option. To set/override the form fields you set properties of an object in the fields
option.
This method takes an object argument where the following properties can be set:
Returns
Example
import http from 'k6/http';
import { sleep } from 'k6';
export default function () {
// Request page containing a form
let res = http.get('https://httpbin.test.k6.io/forms/post');
// Now, submit form setting/overriding some fields of the form
res = res.submitForm({
formSelector: 'form',
fields: { custname: 'test', extradata: 'test2' },
});
sleep(3);
}