#!/usr/bin/env python3 # this is an example that shows how to write your own # scenario. copy this file, rename it, and modify the run() # method to do whatever you want. # the run() method receives a playwright Page object. # you can navigate, click, scrape text, fill forms, # take screenshots, assert content — the full playwright # API is at your disposal. import logging from scenarios.base import BaseScenario logger = logging.getLogger("loadtest.scenario.example") class ExampleScenario(BaseScenario): """ example scenario that demonstrates: - navigating to the target URL - scraping page content - clicking links / navigating around - filling out a form - grabbing data from the page modify this to fit your actual load test needs. """ name = "example" def setup(self, page): logger.debug("[setup] preparing for iteration...") def run(self, page): """ this is where the action happens. each virtual user will execute this method once per iteration. """ logger.info("[run] navigating to base URL...") page.goto("/") page.wait_for_load_state("networkidle") title = page.title() logger.info(f"[run] page title: {title}") # python playwright code goes here - click links, fill forms, scrape content, etc. logger.info("[run] scenario iteration complete.") def teardown(self, page): logger.debug("[teardown] cleaning up after iteration...") def on_response(self, response): """ log every HTTP response for visibility. you can filter by URL pattern, status code, etc. """ status = response.status url = response.url if status >= 400: logger.warning(f"[response] {status} <- {url}") else: logger.debug(f"[response] {status} <- {url}") def on_request(self, request): """ log outgoing requests. """ logger.debug(f"[request] {request.method} -> {request.url}")