Codex

Playwright

Playwright is a browser automation tool that allows you to test your web applications. It is a powerful tool that can be used to test your web applications. It is a great tool for testing your web applications.

Pre-requisites

Installation

For any production use, we recommend using TypeScript when prompted by the installation script. You might want to also agree to Add a GitHub Actions workflow to easily run tests on CI - this comes in handy later on. Other default options are fine.

Don't forget to accept the prompt to install the browsers.

Execution Policy Error

Windows PowerShell's default settings help prevent malicious scripts from being run (eg: VS Code). You can update the policy by running the following command in PowerShell (as Administrator):

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

You can read more about it here.

Folder structure

.
├── tests/                    // This folder contains your actual test scripts
│   └── example.spec.ts       // Example test script
├── .gitignore                // This file helps avoid committing unnecessary files
├── playwright.config.ts      // Global configuration file for Playwright
├── package.json              // To help to track dependencies and scripts
└── package-lock.json

Running tests

You read more about running tests in Playwright documentation.

# Run all tests (in headless mode)
npx playwright test

# Run specific tests (in headless mode)
npx playwright test tests/example.spec.ts

# View the report
npx playwright show-report

# Run all tests (in UI mode, or headed/headful mode)
npx playwright test --ui

# Run all tests in a specific browser
npx playwright test --browser=firefox

Syncing with GitHub

Syncing (and signing in) with your GitHub is a really useful way to not have to remember your local setup - and not worry as much about setting up on a new system.

Read more about it Settings Sync.

Last updated on

On this page