No results for

Powered byAlgolia
⚠️ This is archived documentation for v0.33. Go to the latest version

Selection.serializeArray()

suggest edits

Encode a set of form elements as an array of names and values ([{ name: "name", value: "value" }, ...]). Mimics jquery.serializeArray

Returns

TypeDescription
arrayArray of names and values of the matched form or form elements.

Example

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.serializeArray();
console.log(JSON.stringify(serialized)); // [{"name": "username", "value": ""}]
sleep(1);
}