Browser Test
Playwright-based UI testingEdit
Automate user interactions with Playwright. Navigate pages, fill forms, click buttons, and validate content. Browser tests run in isolated containers on Chromium by default. Add @firefox, @webkit (or @safari) or @mobile to a test title to run it on that browser or device instead.
Example
import { expect, test } from '@playwright/test';
const APP_URL = 'https://the-internet.herokuapp.com';
const CREDENTIALS = { username: 'tomsmith', password: 'SuperSecretPassword!' };
test.describe('authentication flow', () => {
test('user can sign in and sign out', async ({ page }) => {
await page.goto(APP_URL + '/login');
// Fill login form
await page.getByLabel('Username').fill(CREDENTIALS.username);
await page.getByLabel('Password').fill(CREDENTIALS.password);
await page.getByRole('button', { name: 'Login' }).click();
// Verify successful login
await expect(page.getByText('You logged into a secure area!')).toBeVisible();
// Perform logout
await page.getByRole('link', { name: 'Logout' }).click();
// Verify redirect to login page
await expect(page).toHaveURL(APP_URL + '/login');
});
});Create Test
Go to Create → Browser Test
Write your test script
Click Run to validate
Save when passing
Common Actions
| Action | Code |
|---|---|
| Navigate | await page.goto('url') |
| Click | await page.getByRole('button', { name: 'Submit' }).click() |
| Fill input | await page.getByLabel('Email').fill('user@example.com') |
| Check text | await expect(page.locator('selector')).toHaveText('text') |
| Wait | await page.waitForSelector('selector') |
| Screenshot | await page.screenshot({ path: 'file.png' }) |