Practical Playwright/Locust scripts demonstrating common browser-testing scenarios in LoadForge.
Below are several practical examples showcasing different browser-testing use cases in LoadForge. All scripts inherit from PlaywrightUser and use the Locust-Playwright integration found in locust_plugins.users.playwright.
Demonstrates clicking links via text, CSS selector, XPath, and nth-child().
Copy
Ask AI
from locust import taskfrom locust_plugins.users.playwright import PlaywrightUser, PageWithRetry, pwclass ClickUser(PlaywrightUser): @task @pw async def click_examples(self, page: PageWithRetry): await page.goto("/") # By link text await page.click('text=Features') # By CSS id await page.click('#signup-button') # By nth-child await page.click('nav ul li:nth-child(3) a') # By XPath await page.click('//footer//a[contains(., "Contact")]')
These scripts should provide a solid starting point for common browser-testing scenarios. Modify selectors, thresholds, and URLs to match your application.