Menu
Choose a product
Viewing: v1.7.x (latest)
Find another version
Scroll for more
Open source
HTML Forms
Scripting example on how to handle HTML forms.
In many cases using the Selection API (jQuery API clone) to interact with HTML data is enough, but for some use cases, like with forms, we can make things easier providing a higher-level API like the Response.submitForm( [params] ) API.
JavaScript
JavaScript
import http from 'k6/http';
import { sleep } from 'k6';
export default function () {
// Request page containing a form
let res = http.get('https://quickpizza.grafana.com/admin');
// Now, submit form setting/overriding some fields of the form
res = res.submitForm({
formSelector: 'form',
fields: { username: 'admin', password: 'admin' },
});
sleep(3);
}Relevant k6 APIs:
- Response.submitForm([params])
- Selection.find(selector) (the jQuery Selector API docs are also a good resource on what possible selector queries can be made)
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

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.