Agent Wranglers

TST-21Recommended

Test in more than one browser and size

Run the critical journeys in at least two browser engines, at phone and desktop width.

How to do it

Configure projects for Chromium and WebKit, at a desktop size and a phone size. Firefox adds a third engine. Keep the rest of the suite on one browser to save time. Email needs the same, as Test in the clients your readers use says.

Examples

JavaScript example

// playwright.config.js
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'webkit', use: { ...devices['Desktop Safari'] } },
    { name: 'phone-chromium', use: { ...devices['Pixel 7'] } },
    { name: 'phone-webkit', use: { ...devices['iPhone 15'] } },
  ],
});

Python example

# conftest.py for pytest-playwright, run with: pytest --browser chromium --browser webkit
import pytest

@pytest.fixture(params=[(390, 844), (1280, 800)], ids=["phone", "desktop"])
def browser_context_args(browser_context_args, request):
    width, height = request.param
    return {**browser_context_args, "viewport": {"width": width, "height": height}}

How to check

The test report lists each journey passing in two engines and two screen sizes.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/testing/end-to-end-and-browser-tests/browsers-and-sizes">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.