No results for

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

Selection.serialize()

Encode a set of form elements as a string in standard URL-encoded notation for submission. Mimics jquery.serialize

Returns

TypeDescription
stringThe URL-encoded representation 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.serialize();
console.log(serialized); // "username="
sleep(1);
}