k6

A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Guides

Selection.serializeObject()

Encode a set of form elements as an object ({ "inputName": "value", "checkboxName": "value" }).

Returns:

Type
Description

object

Object representation of the matched form or form elements, key is field name and value is field value.

import {parseHTML} from "k6/html";
import {sleep} from "k6";

export default function() {
 const content = `
 <form><input name="username"></form>
  `;

  const doc = parseHTML(content);
  const sel = doc.find('form');
  const serialized = sel.serializeObject();

  console.log(JSON.stringify(serialized)); // {"username": ""}

  sleep(1);
};

Selection.serializeObject()


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.