Run Playwright Tests Remotely in Minutes Using TestGrid

You are here:
< All Topics

Overview

This guide helps you quickly set up and run Playwright tests on a remote browser using TestGrid’s cloud infrastructure. With just a few commands, you can execute your tests, watch them run in real-time, and view detailed logs and videos — all from your local system.


Prerequisites

Before running your first test, ensure the following requirements are met:

  • Node.js installed (v14 or higher)
    Verify installation by running:
    node -v
    npm -v
  • Playwright installed
    If not already installed, use the following commands:
    npm install -D @playwright/test
    npx playwright install
  • TestGrid access
    • Valid User Token
    • Correct SELENIUM_REMOTE_URL
    • Your unique Device ID (UDID)
  • Internet connection for remote browser access

Step 1: Navigate to the Playwright Section in the TestGrid Dashboard

  1. Log in to your TestGrid account.
  2. From the left-hand menu, click on Playwright.
  3. This section provides device options, setup instructions, and the remote execution command.


Step 2: Create or Download a Sample Project

You can either create a new Playwright test project or download a sample project provided on the TestGrid dashboard.

After downloading, open your terminal and navigate to the project directory:
cd ~/Downloads/sample_playwright_project
Ensure the directory contains a valid playwright.config.ts or playwright.config.js file.


Step 3: Execute the Remote Test Command

To run your tests on a remote browser, copy the provided command from the dashboard and execute it in your terminal within the project directory.

Example:
SELENIUM_REMOTE_URL=http://{your_domain}.testgrid.io/browserrun{port} \
SELENIUM_REMOTE_CAPABILITIES='{
"browserName": "chrome",
"tg:udid": "101",
"tg:userToken": "{User_token}"
}' \
npx playwright test --headed

Replace {your_domain}, {port}, and {User_token} with your actual TestGrid values.


Step 4: View Execution Results

You can view the test results in two ways:

  • Local Output
    • Execution logs are shown in the terminal.
    • A local HTML report will be generated.
  • TestGrid Dashboard
    • Navigate to the “Automations” section.
    • You can access:
      • Execution logs
      • Video recordings
      • Session-level reports and artifacts

Happy Testing!

Table of Contents
OSZAR »