Menu
Open source
Selection.serializeArray()
Encode a set of form elements as an array of names and values ([{ name: "name", value: "value" }, ...]
).
Mimics jquery.serializeArray
Returns
Type | Description |
---|---|
array | Array of names and values of the matched form or form elements. |
Example
JavaScript
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);
}
Was this page helpful?
Related documentation
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Performance testing and observability in Grafana Cloud
In this webinar, learn how Grafana Cloud k6 offers you the best developer experience for performance testing.
User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.