Locust Plugins

5.0.0 · active · verified Sat Apr 11

Locust Plugins is a collection of useful extensions for Locust, the open-source load testing tool. It provides implementations for various non-HTTP protocols like Playwright, Selenium/Webdriver, Kafka, FTP, and Telnet 3270, as well as enhanced reporting capabilities for TimescaleDB, Grafana, and Azure Application Insights. The library is currently at version 5.0.0 and maintains an active development cycle, often aligning with updates to Locust core.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic PlaywrightUser, launching a browser, navigating to Google, performing a search, and taking a screenshot. It then manually fires a request event for Locust statistics.

from locust import task, between
from locust_plugins.users.playwright import PlaywrightUser

class MyPlaywrightUser(PlaywrightUser):
    host = "https://www.google.com"
    wait_time = between(2, 5)

    @task
    async def search_for_locust(self):
        page = self.page  # Access the Playwright page object
        await page.goto(self.host)
        await page.fill('textarea[name="q"]', "Locust load testing")
        await page.press('textarea[name="q"]', 'Enter')
        await page.wait_for_selector("#search"); # Wait for search results
        await page.screenshot(path="locust_search.png")
        self.environment.events.request.fire(
            request_type="Playwright",
            name="/search",
            response_time=1000, # Dummy response time
            response_length=100,
            context={
                "user": self.id
            },
            exception=None,
        )

view raw JSON →