← Load Test Directory

Crawling Real HTTP User

Index a site and crawl all the pages with a random delay as a real user would.

You are now browsing the LoadForge locust test directory. You can use these tests as a starting point for your own tests, or use our AI wizard to generate one automatically.



This documentation page provides an example of how to simulate a real user's browsing behavior. It demonstrates a test that replicates user actions on the Locust documentation site. The test identifies all links in the site's table of contents and then accesses these links in a randomized manner, mimicking a genuine user's experience.

Key Features

  • Real User Simulation: This test accesses links with a random delay between 10 to 600 seconds, accurately simulating user load.
  • Versatility: A prime example for those wanting to recreate real user actions on different websites.
  • Driven by Locust: The power of locust.io backs LoadForge, an esteemed open-source load testing tool.

Tried the Wizard?

LoadForge offers a comprehensive test generation wizard. This tool can automatically discover content on your domain and incorporate it into your test file, streamlining the process.

Test Script

Outlined below is the Python script underpinning this test:

import random
from locust import HttpUser, between, task
from pyquery import PyQuery

class AwesomeUser(HttpUser):
    # Simulated user behavior indicates a longer wait time (from 10 to 600 seconds) 
    # between pages due to the considerable content present on each page.
    wait_time = between(10, 600)

    def on_start(self):
        # Initial delay ensures users don't access the site all at once.
        # The starting point for all users is assumed to be the index page.
        self.urls_on_current_page = self.toc_urls

    def index_page(self):
        r = self.client.get("/")
        pq = PyQuery(r.content)
        link_elements = pq(".toctree-wrapper a.internal")
        self.toc_urls = [l.attrib["href"] for l in link_elements]

    def load_page(self):
        url = random.choice(self.toc_urls)
        r = self.client.get(url)
        pq = PyQuery(r.content)
        link_elements = pq("a.internal")
        self.urls_on_current_page = [l.attrib["href"] for l in link_elements]

    def load_sub_page(self):
        url = random.choice(self.urls_on_current_page)
        r = self.client.get(url)

Locust Test Example

LoadForge operates on locust.io's foundation. Thus, if you're a current user of locust, this script is fully compatible. To amplify your testing strategies, consider importing your scripts into LoadForge.


LoadForge equips both novices and experts in load testing with an array of tools and examples, optimizing the efficacy of your tests. The real HTTP user crawling instance is a testament to the myriad ways you can gauge and hone the performance of your online platforms.

Ready to run your test?
Start your first test within minutes.