No results for ""

Powered byAlgolia

HTML Forms

Scripting example on how to handle HTML forms in a load test.

Filling in and submitting forms

One of the most tedious tasks when testing websites and apps are to get all the form filling to work. You have to get all the so-called "correlations" (see above) correct which can take time, even with the help of a scenario recorder as the starting point for getting the basic user journey down into a re-playable test.

import http from "k6/http";
import {sleep} from "k6";

export default function() {
    // Request page containing a form
    let res = http.get("");
    // Now, submit form setting/overriding some fields of the form
    res = res.submitForm({
        formSelector: 'form[action="/post"]',
        fields: { custname: "test", extradata: "test2" },
        submitSelector: "mySubmit",


Relevant k6 APIs: