← Load Test Directory

Efficiently Scraping Page Resources

A comprehensive guide on leveraging LoadForge for automatic fetching of web page resources like styles, javascript, images, etc., using the HttpUserWithResources plugin for Locust.

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.



LoadForge provides a seamless integration with the HttpUserWithResources plugin for Locust, which facilitates the automatic retrieval of crucial web page resources.

While LoadForge offers the automatic retrieval of resources, it's recommended to construct your test in a manner where resources of interest are fetched manually. This is essential because LoadForge won't execute JavaScript. Hence, for AJAX resources, you might want to manually specify them. Alternatively, you can upload a browser recording in the .har format to achieve the same result.

Have You Checked Out the Wizard?

LoadForge boasts a comprehensive wizard for test generation. This wizard can meticulously identify all the static content on your domain and incorporate it into your test file without any hassle!

Crafting the Code

The provided code snippet is designed to request the root of your website (i.e., "/"). Additionally, it will download any matches found for the regular expression: .*[^(js|png|css|gif|woff)]$.

To put it simply, it fetches resources with file extensions: .js, .png, .css, .gif, or .woff.

from locust_plugins.users import HttpUserWithResources
from locust import task

class TestUserWithResources(HttpUserWithResources):
    # The following default values can be modified as per requirements:
    # bundle_resource_stats=False
    # default_resource_filter=".*[^(js)]$"

    def include_resources_default(self):

    def include_resources_true(self):
        self.client.get("/", resource_filter=".*[^(js|png|css|gif|woff)]$")

    def include_resources_false(self):
        self.client.get("/dashboard", include_resources=False)

Did You Know?

LoadForge operates on the robust foundation of Locust. This compatibility ensures that users of open-source Locust can effortlessly adopt this script into their setups. If you're already leveraging Locust, think about integrating your script with LoadForge to elevate your testing experience!

Ready to run your test?
Launch your locust test at scale.