Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/latest/javascript-api/k6-http/response/response-submitform.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/latest/javascript-api/k6-http/response/response-submitform/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
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:
| Param | Type | Description |
|---|---|---|
| formSelector | string | A selector string passed to
Selection.find(selector) to locate the form to fill in and submit. By default this is "form". |
| fields | object | The form fields to set/override. The keys are the form fields names and the values are the form field values. |
| submitSelector | string | A selector string used to locate the submit button in the form. By default this is '[type="submit"]'. |
| params | object | A Params (k6/http) object that will be forwarded to the form submit request. Can be used to set headers, cookies etc. |
Returns
| Type | Description |
|---|---|
| Response (k6/http) | The form submit response. |
Example
import http from 'k6/http';
import { sleep } from 'k6';
export default function () {
// Request page containing a form
let res = http.get('https://quickpizza.grafana.com/admin');
// Now, submit form setting/overriding some fields of the form
res = res.submitForm({
formSelector: 'form',
fields: { username: 'test', password: 'test2' },
});
sleep(3);
}Was this page helpful?
Related resources from Grafana Labs

