Run on Mobile & Desktop

Execute your tests with Microsoft Playwright

Codeceptjs-BDD implements all the required capabilities to run Playwright tests on Mobile, Tablets, and Desktop layouts.

👺 About Playwright

Playwright is a Node library to automate the Chromium, WebKit and Firefox browsers with a single API. It enables cross-browser web automation that is ever-green, capable, reliable and fast.

Headless is supported for all the browsers on all platforms.

Codeceptjs-BDD integrates the Playwright with WebDriver.

🚀 To run on Playwright

If you have setup framework through the Codeceptjs-BDD CLI, then you'd have an option to select Default driver. Set the Default Driver in codecept.env file to be Playwright.

Alternatively, set the DRIVER to be ~playwright thru CLI,

$ DRIVER=playwright yarn acceptance

📱 Run on Mobile Devices

Playwright can run your tests various Mobile and Tablets layouts. The Codeceptjs-BDD implements all the required capabilities to run on any combinations of Mobile-Tablets/Browsers thru device param.

Playwrights devices are available here

$ DRIVER=playwright yarn acceptance --profile device:'<name-of-device>':<browser>

<name-of-device> is the Mobile/Tablet names found here.

e.g.

$ yarn acceptance --profile device:'iPhone 11':safari

yarn acceptance --profile device:'Galaxy Note II':chrome

🖥 Run on Desktop Browsers

Default browser for Playwright is chromium. To run on different desktop browsers,

$ yarn acceptance --profile playwright:chrome
$ yarn acceptance --profile playwright:firefox
$ yarn acceptance --profile playwright:safari

Run on Google Chrome: Stable Chrome build

$ yarn acceptance --profile playwright:google:chrome

🤖 Run Headless

$ HEADLESS=false yarn acceptance

👉 Please note: Playwright support was added from the codeceptjs-configure@4

+ Add Playwright support for existing framework before version 4

Please note: The Playwright support was included with the codeceptjs-configure@4 version. If you have previous version installed, please update your codeceptjs.conf.js declaration and dependencies as defined here and update your config creation as defined here.

And, install below dependencies

yarn add codeceptjs-configure@^4 -D

Trigger Method on DOM Component

I.usePlaywrightTo('trigger method on component', async ({ page }) => {
  await page.$eval(DOM_COMP, el =>
    el.<method-name>(<any-param>)
  );
});

Record Playwright Video and Attach on Allure Report

To enable this feature, add the below ENV property to the codecept.env file,

RECORD_VIDEO_ON_FAIL = true; // only to record video on Fail & attach to Allure
RECORD_PLAYWRIGHT_VIDEO = true; // record and attach Playwright video regardless of results


### Record Playwright Trace on FAIL

To enable this feature, add the below ENV property to the `codecept.env` file,

```js
RECORD_TRACE_ON_FAIL = true;

Start Playwright Browser with Proxy

Set env variable mentioned below, and codecept-bdd will start playwright with proxy,

PLAYWRIGHT_BROWSER_PROXY = <your-proxy>
``

More info trace: https://codecept.io/playwright/#trace


SelenoidIntercept Request