Documentation Index
Fetch the complete documentation index at: https://docs.loadforge.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
While testing, it’s crucial to simulate user behavior as realistically as possible. One key aspect of this simulation is introducing waits or pauses that a typical user might experience, like reading a webpage or waiting for some data. By default, LoadForge’swait_time attribute allows you to set such pauses. This guide will delve deeper into customizing these waits and understanding their applications.
wait_time vs. time.sleep
There are two primary ways to introduce waits in your tests:-
wait_time: This attribute specifies the pause between tasks. For example, onceload_pageconcludes, the simulated user would wait for the duration specified bywait_timebefore initiating the next task. In our example below, after theload_pagetask concludes, a user will pause for a duration anywhere between 10 to 20 seconds. -
time.sleep: This function allows for more specific pauses, right at the point it’s called within your test. So if you want a user to pause immediately after a particular HTTP request and before another,time.sleepcan be used.
Example Code
Here’s an example:/page1, waiting for a duration between 10 to 60 seconds (perhaps reading content or interacting with elements), and then navigating to /page2, where they pause again for a fixed 20 seconds.
LoadForge leverages the power of the open-source
locust library. This means that if you’re already a locust user, you can directly port this script. If you wish to amplify your testing capabilities, consider importing your script into LoadForge!