Submitting Forms
Examples of how to submit forms during your load tests.
Testing form submissions is a crucial part of load testing. Many applications rely on forms for authentication, data collection, and business logic (e.g., logins, signups, contact forms).
There are multiple ways to submit form data, including traditional web forms and JSON-based API submissions. Below are examples of both methods.
Tip: Use LoadForge’s Browser Recorder to automatically capture and replay form submissions. This simplifies setting up real-world interactions.
Submitting Standard Web Forms
A standard HTML form submission involves sending form data via a POST
request. Below is an example of a contact form submission in LoadForge:
Example: Contact Form Submission
Handling Redirects
Many form submissions trigger redirects (e.g., login forms). If your test needs to follow a redirect, add allow_redirects=True
:
For more examples, see:
Submitting JSON Data
Modern applications often use APIs to handle form data as JSON payloads. Below is an example of submitting JSON data in LoadForge:
Example: JSON POST Request
Common API Issues
If your JSON form submissions fail, check for:
- Incorrect Content-Type – Ensure
Content-Type: application/json
is set. - Missing Headers – Some APIs require authentication tokens.
- CSRF Protection – Some web apps reject requests without a CSRF token.
For more details, see:
Debugging Form Submissions
If your test isn’t working, try:
- Manually submitting the form in your browser and checking network requests in Developer Tools > Network Tab.
- Using LoadForge’s Debugger to analyze failed requests.
- Enabling logging to capture detailed request responses:
By mastering form submissions, you can simulate real user behavior, ensuring your application performs well under load. 🚀