Selection.serialize()
将一组表单元素编码为标准 URL 编码格式的字符串以供提交。模仿了 jquery.serialize
返回值
类型 | 描述 |
---|---|
string | 匹配到的表单或表单元素的 URL 编码表示。 |
示例
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);
}