Page tree
Skip to end of metadata
Go to start of metadata

Playwright is a testing tool for web applications using modern JavaScript frameworks.

Playwright enables you to write end-to-end tests and can test anything that runs on a browser.


Article contents:


Playwright support is available only in SaaS clouds.

In order to run Playwright projects in Cloud, you need to have a Docker Swarm and Execution Service set up in your environment.

Playwright projects are run inside containers in Docker Swarm via Execution Service API.

In order to run Playwright project Cloud need to have Browser license.

Execution Service API

The role of the user performing the Rest Operation is specified by the Authorization header.

For more information please visit How To Execute Rest API, for a detailed example.

Start a Playwright execution

Enables users to run Playwright projects.
Playwright projects are run asynchronously, the response received is immediate.

POST /api/v1/executions


Parameters

Name

Type

Mandatory

Description

typeStringYes

Specify execution type. for Playwright use Playwright

projectFileYes

The Playwright project to run.
Compress the entire playwright project and select the .zip file.
Please read the next section for more information about the project.

confJSON StringNo

A configuration file for the requested execution.
Please read the section below for more information about the configuration.

POST Playwright Execution Response
{
    "status": "SUCCESS",
    "data": {
        "Test Run Id": "3520546",
        "Link to Reporter": "https://CLOUD_SERVER/reporter/#/test-view-view/-1?testView={%22byKey%22:%22test.run.id%22,%22byKeyValue%22:%223520546%22}"
    },
    "code": "OK"
}


Playwright project

Playwright project can contain a config file named playwright.config.js which must be located under the root folder.
In order to have a video in the report add the following property to the config file: video: 'on' under the 'use' section.

Playwright configuration

In order to run Playwright project, a configuration must be supplied.
There are 2 options to add configuration:

  1. add the conf parameter as a JSON string to the POST request.
  2. a file named digitalai.json with the required configuration in the root directory of the project

When supplying both options, the digitalai.json is ignored

Configuration parameters:

Name

Type

Mandatory

Description

browsersListYes

A list of browser names and playwright versions to run the project on. each entry in the list is as follows:

{
	"browser": "browser name"
	"imageVersion": "playwright image version"
}

Supported browsers are Chromium, Firefox and Webkit.

Playwright configuration example
{
  "browsers": [{
      "browser": "chromium",
      "imageVersion": "1.22.0"
    },
    {
      "browser": "firefox",
      "imageVersion": "1.23.1"
    },
    {
      "browser": "webkit",
      "imageVersion": "1.22.1"
    }
  ]
}

Get Playwright execution status

Get the Playwright execution status

Get status privileges:

  • User can get only his own session status
  • Project admin can get his own session status and can get statuses from other users of his project
  • Admin can get any session status on his cloud


GET  /api/v1/executions/{Execution_ID}/status
Get Playwright Execution Response
{
    "code": "OK",
    "data": {
        "Test Run Id": "3023f8be-783e-4b70-b830-3ca2e4bd3f7a",
        "Test Run State": "RUNNING",
        "Number of requested browsers": "2",
        "Number of browsers completed": "0",
        "Number of browsers running": "2",
        "Number of browsers in queue": "0",
        "Link to Reporter": "https://CLOUD_SERVER/reporter/reporter/dashboard/#/test-view-view/-1?testView=%7B%22byKey%22:%22test.run.id%22,%22byKeyValue%22:%223023f8be-783e-4b70-b830-3ca2e4bd3f7a%22%7D"
    },
    "status": "SUCCESS"
}

Cancel Playwright execution

Cancel Playwright execution project by test run id.

Cancel privileges:

  • User can cancel only his own execution
  • Project admin can cancel his own execution and can cancel executions from other users of his project
  • Admin can cancel any execution on his cloud


PUT  /api/v1/executions/{executionId}/actions/cancel
Response if session canceled successfully
Execution session id - <session id> canceled
Response if user has no privileges to cancel the session
{
    "status": "ERROR",
    "data": {
        "User": "Security Error"
    },
    "code": "FORBIDDEN"
     
}

Get Playwright execution logs

Get the logs of a certain Playwright run.

Get logs privileges:

  • User can get only his own session logs
  • Project admin can get his own session logs and can get logs from other users of his project
  • Admin can get any session logs on his cloud
GET  /api/v1/executions/{Execution_ID}/logs

Returned response is a zip file with the logs or an error message if any error occurred.

  • No labels