If you're new to mabl and want to leverage your existing set of Playwright tests, follow these steps to import your Playwright tests to mabl via the mabl CLI.
The importer tool in the mabl CLI aims to create a mabl test that is as close as possible to the original Playwright test. However, there are certain limitations:
- Variables, code blocks, if statements, and loops are not migrated during the import session.
- Mabl tests do not support Playwright’s array assertions or assertions using regular expressions.
If you choose to migrate Playwright tests, follow the recommended steps for updating tests at the end of this article to set your mabl tests up for success.
Step 1: Install the mabl CLI
If the mabl CLI isn't installed on your machine, run the following command:
npm install -g @mablhq/mabl-cli
If you've already installed the mabl CLI, run the following command to update to the latest version:
npm install -g @mablhq/mabl-cli@latest
Step 2: Log into the mabl CLI
Run the following command to log into the mabl CLI:
mabl auth login
This command prompts the mabl CLI to open the mabl login page in a browser window. To complete authentication:
- Log into mabl using your usual method: username and password, Google auth, or SSO.
- Copy the authorization code from the browser window.
- Paste the authorization code in the mabl CLI.
- Press enter to finish logging in.
Step 3: Import tests
To import tests, use the mabl tests import playwright
command. You may import Playwright tests at runtime or from a trace.zip file.
For a full list of import options, run the command mabl tests import playwright -h
in the CLI or see the reference article on importing tests in the mabl CLI.
Import at runtime
To import Playwright tests at runtime, run the mabl tests import playwright
command with the --path
option:
mabl tests import playwright --path <path-to-playwright-tests> --project <project-path>
If you include the --project
option, the mabl CLI can convert the baseURL of the Playwright project into an application URL in your mabl test(s).
The mabl CLI runs the Playwright test(s) using the Playwright version installed on your machine. If all the tests pass, the mabl CLI prompts you to choose from one of the following options to finish the import session:
- View the test description
- Run the test locally
- Save the test
- Discard the test and exit
Import from a trace file
Link to this doc
To import a single Playwright test from a trace.zip file, run the mabl tests import playwright
command with the --trace-file
option:
mabl tests import playwright --trace-file <path-to-trace-file> --project <project-path>
To import multiple Playwright tests from a directory of trace.zip files, run the mabl tests import playwright
command with the --trace-path
option:
mabl tests import playwright --trace-path <path-to-trace-directory> --project <project-path>
Step 4: Update tests in mabl
To set your migrated tests up for success in mabl, take the following next steps:
Check for unsupported steps
If a Playwright test contains steps that mabl doesn't support, the unsupported steps become echo steps or are listed in a description at the end of the test.
Migrated Playwright test with unsupported steps
Update find actions
When you import a test from Playwright, all steps that interact with page elements are converted into custom find steps in mabl. To fully reap the benefits of mabl's find strategies, including auto-heal, Configure Find, and Intelligent Wait, we strongly recommend replacing the imported custom find steps with recorded actions in the mabl Trainer.
The Playwright import command is an experimental offering. We highly encourage you to provide feedback on this feature in the mabl Product Portal.