LambdaTest Playwright Testing: Cloud Execution and Parallel Runs

LambdaTest Playwright Testing: Cloud Execution and Parallel Runs

LambdaTest supports Playwright via the @lambdatest/playwright-driver package, which replaces Playwright's built-in browser launcher with a remote session on LambdaTest's cloud grid. You get parallel execution across Chrome, Firefox, Safari, and Edge without downloading browser binaries or managing infrastructure.

Why Use LambdaTest for Playwright

Playwright already runs multiple browsers locally, but local runs have limits: Safari/WebKit on Linux requires workarounds, parallel sessions consume RAM linearly, and you can't easily test on real Windows or macOS without those machines. LambdaTest's cloud gives you real OS + browser combinations and scales parallel sessions without touching your local environment.

Installation

npm install @lambdatest/playwright-driver

That's the only addition. Your existing Playwright test files don't change.

Basic Setup

LambdaTest's Playwright driver wraps the standard Playwright API. The connection looks like this:

// lt-setup.js
const { chromium } = require('@lambdatest/playwright-driver');

const capabilities = {
  browserName: 'Chrome',
  browserVersion: 'latest',
  'LT:Options': {
    platform: 'Windows 11',
    build: 'Playwright Build 1.0',
    name: 'My First Test',
    user: process.env.LT_USERNAME,
    accessKey: process.env.LT_ACCESS_KEY,
    network: true,
    video: true,
    console: true,
  }
};

(async () => {
  const browser = await chromium.connect({
    wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
  });

  const page = await browser.newPage();
  await page.goto('https://example.com');
  console.log(await page.title());

  await page.evaluate(() => {},
    `lambdatest_action: ${JSON.stringify({ action: 'setTestStatus', arguments: { status: 'passed', remark: 'Test passed' }})}`
  );

  await browser.close();
})();

The wsEndpoint is LambdaTest's CDP (Chrome DevTools Protocol) endpoint. Playwright connects to it the same way it connects to a local browser — from your test's perspective, nothing changes.

Playwright Config for LambdaTest

For teams using playwright.config.ts, the cleanest approach is environment-based switching:

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

const isLambdaTest = !!process.env.LT_USERNAME;

const ltCapabilities = (browserName: string, platform: string) => ({
  browserName,
  browserVersion: 'latest',
  'LT:Options': {
    platform,
    build: process.env.CI_BUILD_ID || 'local',
    name: 'Playwright Suite',
    user: process.env.LT_USERNAME,
    accessKey: process.env.LT_ACCESS_KEY,
    video: true,
    network: true,
  }
});

export default defineConfig({
  testDir: './tests',
  timeout: 60000,
  workers: isLambdaTest ? 4 : undefined,
  use: {
    trace: 'on-first-retry',
  },
  projects: isLambdaTest
    ? [
        {
          name: 'Chrome Windows',
          use: {
            connectOptions: {
              wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
                JSON.stringify(ltCapabilities('Chrome', 'Windows 11'))
              )}`
            }
          }
        },
        {
          name: 'Firefox Windows',
          use: {
            connectOptions: {
              wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
                JSON.stringify(ltCapabilities('MicrosoftEdge', 'Windows 10'))
              )}`
            }
          }
        },
        {
          name: 'Safari macOS',
          use: {
            connectOptions: {
              wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
                JSON.stringify(ltCapabilities('pw-webkit', 'macOS Ventura'))
              )}`
            }
          }
        },
      ]
    : [
        { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
        { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
      ],
});

Set LT_USERNAME and LT_ACCESS_KEY to switch between local and cloud execution.

Browser Name Values

LambdaTest uses specific strings for browserName in Playwright mode:

Browser browserName value
Chrome Chrome
Firefox Firefox
Safari (WebKit) pw-webkit
Edge MicrosoftEdge

Parallel Browser Matrix

The real value is running the same test suite across all four browsers simultaneously. With 4 workers (workers: 4 in config), Playwright distributes tests across the browser projects in parallel.

For a suite of 20 tests across 4 browser projects (80 total test runs) at 30s per test:

  • Sequential: 2400s (40 minutes)
  • Parallel (4 workers): ~600s (10 minutes)
  • Parallel (8 workers): ~300s (5 minutes)

LambdaTest's concurrent session limit depends on your plan. Check your plan before setting high worker counts — excess sessions queue rather than fail.

GitHub Actions CI

# .github/workflows/playwright.yml
name: Playwright Tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  playwright:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Run Playwright tests on LambdaTest
        env:
          LT_USERNAME: ${{ secrets.LT_USERNAME }}
          LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
          CI_BUILD_ID: ${{ github.run_id }}
        run: npx playwright test --reporter=list

      - name: Upload Playwright report
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: playwright-report/

The CI_BUILD_ID maps to the build name in LambdaTest's dashboard, letting you trace a GitHub Actions run to the corresponding cloud sessions.

Marking Test Status

Playwright tests need to report pass/fail status to LambdaTest explicitly. Use a global teardown or fixture:

// fixtures.ts
import { test as base } from '@playwright/test';

export const test = base.extend({
  page: async ({ page }, use, testInfo) => {
    await use(page);

    const status = testInfo.status === 'passed' ? 'passed' : 'failed';
    const remark = testInfo.error?.message || 'Test completed';

    await page.evaluate(
      ([s, r]) => {
        // @ts-ignore
        window.lambdatest_action = JSON.stringify({
          action: 'setTestStatus',
          arguments: { status: s, remark: r }
        });
      },
      [status, remark]
    );
  }
});

Use this test import instead of @playwright/test in your test files.

Testing Localhost Apps

For apps running on localhost during CI, use LambdaTest Tunnel:

# In CI, before running tests
wget -q https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip
unzip -q LT_Linux.zip
./LT --user $LT_USERNAME --key $LT_ACCESS_KEY --daemon start

Add "tunnel": true to your LT:Options. The tunnel proxies traffic from LambdaTest's cloud nodes to your CI machine's localhost.

Debugging Failures

When a Playwright test fails on LambdaTest:

  1. Video replay — available immediately in the test dashboard. Shows exactly what rendered.
  2. Trace viewer — if trace: 'on-first-retry' is set, download the trace file from the dashboard and open with npx playwright show-trace trace.zip.
  3. Network logs — HAR file captures all HTTP traffic. Useful for API test failures.
  4. Console logs — JS errors that don't throw (warnings, unhandled rejections).

The trace viewer is the fastest debugging tool for Playwright failures — it shows each action, the DOM snapshot at that point, and the network request timeline.

Comparing LambdaTest vs Playwright Cloud

Feature LambdaTest Playwright Cloud (MS)
Real browsers Yes Yes
Safari/WebKit Real Safari on macOS WebKit engine
Parallel sessions Plan-based Plan-based
Test analytics Yes (detailed) Basic
CI integrations GitHub, GitLab, Jenkins, CircleCI GitHub
Pricing entry ~$15/mo ~$10/mo
Mobile testing Yes (Appium) No

LambdaTest's advantage is the broader platform — you can run Selenium, Playwright, and Cypress from one account, share results in one dashboard, and extend to mobile testing without switching tools.

Start now free