No results for ""

Powered byAlgolia

HTML Forms

suggest edits

Scripting example on how to handle HTML forms.

In many cases using the Selection API (jQuery API clone) to interact with HTML data is enough, but for some use cases, like with forms, we can make things easier providing a higher-level API like the Response.submitForm( [params] ) API.

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

export default function() {
  // Request page containing a form
  let res = http.get('https://httpbin.org/forms/post');

  // Now, submit form setting/overriding some fields of the form
  res = res.submitForm({
    formSelector: 'form',
    fields: { custname: 'test', extradata: 'test2' },
  });
  sleep(3);
}

Relevant k6 APIs: