Skip to main content

Defining Playwright Engine Tests as Text Files

How is Playwright Engine different from the Playwright npm module integration?

Read the migration guide here.

The Playwright Testing Engine executes your testing scripts natively in the platform, by specifying three things:

  • The target URL of your website (private or public).
  • A JavaScript file with your tests.
  • And the exported method you want to execute.

Tracetest Playwright Engine test definition YAML:

trigger:
type: playwrightengine
playwrightEngine:
target: ${env:TARGET_URL}
script: ./script.js
method: importPokemon

Playwright script.js definition:

const { expect } = require("@playwright/test");

// [...]

async function importPokemon(page) {
expect(await page.getByText("Pokeshop")).toBeTruthy();

await page.click("text=Import");
await page.getByLabel("ID").fill("143");

await Promise.all([
page.waitForResponse(
(resp) => resp.url().includes("/pokemon/import") && resp.status() === 200
),
page.getByRole("button", { name: "OK", exact: true }).click(),
]);
}

module.exports = { importPokemon };