Vladislav Timashenkov from InfoWatch shares a streamlined method for building a UI test automation framework. The approach emphasizes direct use of Playwright capabilities rather than wrapping them in custom abstractions.
The framework starts by launching a single Chromium browser process for the entire test session using a session-scoped fixture. Settings such as headless mode and slow motion are stored separately in BROWSER_SETTINGS to allow environment-specific configuration through variables or files.
Authentication is handled without UI interaction. A factory fixture uses the requests library to call the login API endpoint and extracts cookies for later use in browser contexts. This design supports multiple users during a single test run.
Isolated BrowserContext instances provide test separation. A context factory fixture accepts authentication data, applies CONTEXT_SETTINGS including base URL and locale, and ensures all contexts are closed after each test function.
The page fixture combines the authenticated user data with the context factory to deliver a ready-to-use page object. Because the fixture scope is function-level, every test receives a fresh page with pre-applied cookies.
Page Object classes encapsulate business logic only. Locators are exposed as properties that return fresh Locator instances on each access, taking advantage of Playwright’s lazy evaluation and automatic waiting. Methods such as create_tag and delete_tag_by_name perform interactions without additional explicit waits.
A sample test demonstrates creating a tag with generated data from Faker and verifying visibility using the expect assertion API. The article concludes that this minimal infrastructure scales easily as new page objects are added.


