Create Performance tests (Playwright)

BlazeMeter supports running Playwright tests as part of your test execution workflows. This enables you to bring existing tests written in TypeScript and based on Playwright into BlazeMeter and execute them without rewriting tests in JMeter.

This capability is designed for customers who already use Playwright and want to leverage BlazeMeter for test execution and reporting.

Playwright in BlazeMeter allows you to:

  • Reuse existing Playwright test code in BlazeMeter.

  • Execute Playwright tests similarly to other supported executors, such as Selenium.

  • Integrate Playwright tests into BlazeMeter workflows instead of maintaining a separate execution setup.

This article focuses on BlazeMeter‑specific usage. General Playwright concepts are not covered here.

Create your Playwright project

The first step is to create a Playwright project. You can find this complete Playwright-based test suite and Taurus config to run it with in the examples/playwright folder of Taurus's repo.

Your Playwright project must consist of at least these files:

  • package.json—Lists the dependencies of the project. These are installed automatically when executing using the Taurus Playwright executor

  • playwright.config.ts—The Playwright configuration file

    Copy

    Example playwright.config.ts

    import { defineConfig, devices } from '@playwright/test';
     
    /**
     * See https://playwright.dev/docs/test-configuration.
     */
    export default defineConfig({
      testDir: '.',
      /* Run tests in files in parallel */
      fullyParallel: true,
      /* Fail the build on CI if you accidentally left test.only in the source code. */
      forbidOnly: !!process.env.CI,
      /* Retry on CI only */
      retries: process.env.CI ? 2 : 0,
      /* Opt out of parallel tests on CI. */
      workers: process.env.CI ? 1 : undefined,
      /* Reporter to use. See https://playwright.dev/docs/test-reporters */
      reporter: 'json',
      /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
      use: {
        /* Base URL to use in test actions like `await page.goto('/')`. */
        // baseURL: 'http://127.0.0.1:3000',
        baseURL: process.env.BASE_URL,
        /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
        trace: 'on-first-retry',
        video: {
          mode: 'on',
          size: { width: 640, height: 480 }
        }
      },
     
      /* Configure projects for major browsers */
      projects: [
        {
          name: 'chromium',
          use: { ...devices['Desktop Chrome'] },
        },
     
        {
          name: 'firefox',
          use: { ...devices['Desktop Firefox'] },
        },
     
        {
          name: 'webkit',
          use: { ...devices['Desktop Safari'] },
        }
      ],
    });
  • example.spec.ts—The test file

    Copy

    Example example.sec.ts file

    import { test, expect } from '@playwright/test';
     
    test('has title', async ({ page }) => {
      await page.goto("/");
     
      // Expect a title "to contain" a substring.
      await expect(page).toHaveTitle(/BlazeDemo/);
    });
     
    test('reserve flight', async ({ page }) => {
      await page.goto('/');
     
      await page.getByRole('button', { name: 'Find Flights' }).click();
     
      await expect(page).toHaveTitle(/reserve/);
     
      await page.getByRole('button', { name: 'Choose This Flight' }).nth(1).click();
     
      await expect(page).toHaveTitle(/Purchase/);
     
    });

Example package.json: https://github.com/Blazemeter/taurus/blob/master/examples/playwright/package.json

Create a Playwright Performance test in BlazeMeter

  1. In the main menu, click the Performance tab.
  2. Click Create Test.
  3. Select a project.
  4. Click Performance Test. The Configuration tab for the test opens.
  5. Upload the Playwright file. Either click the plus button and browse to the file on your hard drive, or drag and drop the file into the upload area.
    Copy
    Sample Playwright usage
    execution:
    - executor: playwright
      scenario: playwright_test
      iterations: 10
      hold-for: 1m
      concurrency: 5

    settings:
      env:
        BASE_URL: https://blazedemo.com/

    scenarios:
        playwright_test:
            script: example.spec.ts # points to the TypeScript file with tests
            browser: firefox
            test: has title # Omit the test name to run all tests. Here, "has title" is the name of the test.

Advanced Playwright usage

  • Taurus can repeat test suite executions in a loop until the desired number of iterations is complete (for each concurrent user), or until the hold-for time is exceeded. To specifiy the number of concurrent users (also known as workers in Playwright), define the concurrency option.

  • Playwright does not support infinite iterations. If you use hold-for without iterations, Taurus sets Playwright's repeat-each to 1000.

  • To pass the base URL to your test as an environment variable, define the BASE_URL option.

  • To override the browser settings from your Playwright test configuration, define the browser option to: chromium, firefox, webkit, or other.

  • To execute a single test from the suite, define the test field.

Run Playwright tests in BlazeMeter

  1. Name your test.

  2. (Optional) Click Debug Test to validate your test configuration.
    For more information about debugging, see Debug Test: Low-Scale Test Run and Enhanced Logging.

  3. Click Run Test.