Skip to content

Playwright

Playwright integration helpers for Rapise. Provides:

  • Running Playwright test runner and importing JSON report
  • Invoking Playwright against the current Rapise WebDriver (via CDP)
  • AI element discovery that converts AI result to Rapise locator

Action Summary

Action Description
DoImportJsonReport Import report in JSON format produced by Playwright earlier.
DoInvoke Invoke user callback, passing current browser as a parameter: cb({page,expect,browser}).
DoPlay Run playwright test cmdParams and import results into Rapise test report.
GetElementByAi Use query to find an element by plain text description.

Action Detail

DoImportJsonReport

Import report in JSON format produced by Playwright earlier.

Playwright.DoImportJsonReport(path)

Parameters:

Name Type Description
path string Path to JSON report file.
Optional, Default: "test-results.json".

Returns:

boolean: true if report parsed and processed.

DoInvoke

Invoke user callback, passing current browser as a parameter: cb({page,expect,browser}).

Examples:

Playwright.DoInvoke(async ({page,expect}) {
    await expect(page).not.toHaveURL('error');
})

Playwright.DoInvoke(callBack)

Parameters:

Name Type Description
callBack function Async function to run: async ({page, expect, browser}) => { ... }

Returns:

boolean |
object: true if callback returns undefined; otherwise returns callback result (or false if exception).

DoPlay

Run playwright test cmdParams and import results into Rapise test report.

Examples:

// Run all test *.spec.js / *.spec.ts files (with respect to playwright.config.ts / playwright.config.js)
Playwright.DoPlay();
// Run files that have my-spec or my-spec-2 in the file name
Playwright.DoPlay("my-spec my-spec-2");
// Run tests that are in line 42 in my-spec.ts
Playwright.DoPlay("my-spec.ts:42");
// Run tests in headed browsers
Playwright.DoPlay("--headed");

Playwright.DoPlay(cmdParams)

Parameters:

Name Type Description
cmdParams string Additional Playwright CLI parameters after playwright test --reporter=json.
Optional, Default: "".

Returns:

boolean: true on completion (errors are reported as soft asserts).

GetElementByAi

Use query to find an element by plain text description. The more detailed description the better.

Playwright.GetElementByAi(query)

Parameters:

Name Type Description
query string Plain text description of an element to find (the more specific the better).

Returns:

HTMLObject |
boolean: HTMLObject (Rapise) when element is found, otherwise false.