From c996b2cf50138e99ef102902149dab373b9a0458 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 20 Sep 2024 11:57:33 +0200 Subject: [PATCH 1/4] Update Readme.md: Overhaul :-) Don't merge yet - more to come... --- Readme.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index 54f5496..5c3a568 100644 --- a/Readme.md +++ b/Readme.md @@ -1,23 +1,24 @@ # Playwright module for Codeception -🚀 This is the **first and the only module that allows [Playwright](https://playwright.dev) testing in PHP**. Playwright allows testing in Chrome, Firefox, Webkit (safari). It is faster and more reliable alternative to Selenium WebDriver. Finally it is available in PHP! +🚀 This is the **first and the only library that features [Playwright](https://playwright.dev) testing in PHP**. Playwright allows testing in Chrome, Firefox, Webkit (safari). It is faster and more reliable alternative to Selenium WebDriver. Finally it is available in PHP! This module does not implement Playwright API in PHP, rather proxies requests to Playwright helper of [CodeceptJS](https://codecept.io). This is possible because Codeception and CodeceptJS share the same architecture principles, and the interface for web testing is quite the same. +> [!Warning] +> This module is experimental. It is in early development stage. Please report any issues you find. + > [!Note] -> This module can be used as a replacement for WebDriver module. Comparing to WebDriver module, Playwright module can **speed up your tests x3 times**, run in headless mode, record videos, and stack traces out of the box +> This module can be used as a drop-in replacement for Codeception's [module WebDriver](https://codeception.com/docs/modules/WebDriver). Comparing to WebDriver, Playwright can **speed up your tests x3 times**, run in headless mode, record videos and stack traces out of the box +> Since this module provides the same API as module WebDriver, you can use it in your tests without any changes. ## Requirements * PHP 8.1+ -* NodeJS 20+ +* [NodeJS 20+](https://nodejs.org/) ## Installation -> [!Warning] -> This module is experimental. It is in early development stage. Please report any issues you find. - Install NodeJS part of this module, it will install Playwright and CodeceptJS ``` @@ -104,11 +105,7 @@ modules: ## API -This module provides the same API as WebDriver module. You can try to use it in your tests without any changes. - -For the full command list see [WebDriver module reference](https://codeception.com/docs/modules/WebDriver#dontSeeElement). - -Playwright-specific commands are also available in [CodeceptJS Playwright Helper](https://codecept.io/helpers/Playwright/) +Besides supporting all commands of Module Webdriver, there are Playwright-specific commands available in [CodeceptJS Playwright Helper](https://codecept.io/helpers/Playwright/). ## Example From 9ee9e46cd3f60124eef6f5a9aaaf6f447033fa57 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 20 Sep 2024 12:45:05 +0200 Subject: [PATCH 2/4] Update Readme.md --- Readme.md | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Readme.md b/Readme.md index 5c3a568..bad975a 100644 --- a/Readme.md +++ b/Readme.md @@ -15,30 +15,26 @@ This module does not implement Playwright API in PHP, rather proxies requests to ## Requirements * PHP 8.1+ -* [NodeJS 20+](https://nodejs.org/) +* [Node.js 20+](https://nodejs.org/) ## Installation -Install NodeJS part of this module, it will install Playwright and CodeceptJS - -``` +Install the Node.js part of this module; this will install Playwright and CodeceptJS: +```bash npm install codeception-module-playwright ``` Install Playwright browsers - -``` +```bash npx playwright install --with-deps ``` - -Install PHP part of this module - +Install the PHP part of this module: ```bash composer require codeception/module-playwright --dev ``` ## Configuration -Enable module in `codeception.yml`: +Enable the module in `codeception.yml`: ```yaml modules: @@ -50,26 +46,24 @@ modules: ``` Most common config values are: -* `url` - base url to open pages from -* `browser` - either `chromium`, `firefox`, `webkit` -* `show` - (default: `true`) to show browser or set to `false` to run tests in headless mode -* `timeout` - (default: `5000`) timeout (in ms) for all Playwright operations -* `pw_start` - (default: `true`) start Playwright Server (Proxy to CodeceptJS) automatically. Set to `false` and run server manually in case server doesn't start. -* `pw_server` - (default: 'http://localhost:8191') url of Playwright Server -* `pw_debug` - (default: `false`) print Playwright Server debug information -* `video` - save video on fail -* `trace` - save traces on fail +* `url`: Base url to open pages from +* `browser`: Either `chromium`, `firefox`, `webkit` +* `show` (default: `true`): Show the browser or run tests in headless mode +* `timeout` (default: `5000`): Timeout (in ms) for all Playwright operations +* `pw_start` (default: `true`): Start Playwright server (proxy to CodeceptJS) automatically. Set to `false` and run the server manually in case the server doesn't start. +* `pw_server` (default: `http://localhost:8191`): Url of Playwright server +* `pw_debug` (default: `false`): Print Playwright server debug information +* `video`: Save video on fail +* `trace`: Save stack traces on fail More configuration options are is listed on [CodeceptJS Playwright page](https://codecept.io/helpers/Playwright/#configuration) - > [!Tip] > This module is designed as drop-in WebDriver module replacement, you can change `WebDriver` to `Playwright` in your tests and try how it works! - ## Usage -Playwright module requires NodeJS server to be running. Playwright module will start it and stop automatically. Default port is **8191**. +Playwright module requires the Node.js server to be running. Playwright module will start it and stop automatically. Default port is **8191**. If you want to disable automatic server start, set `start` option to `false`: From 8bbfea840067416219f9563b424cec08c29fffbe Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 20 Sep 2024 16:43:30 +0200 Subject: [PATCH 3/4] Update Readme.md --- Readme.md | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/Readme.md b/Readme.md index bad975a..3ad985f 100644 --- a/Readme.md +++ b/Readme.md @@ -40,26 +40,20 @@ Enable the module in `codeception.yml`: modules: enabled: - Playwright: - url: 'http://localhost' - browser: 'chromium' - show: true + url: 'http://localhost' # Base url to open pages from + browser: 'chromium' # Either `chromium`, `firefox`, `webkit` + show: true # Show the browser (=default) or run tests in headless mode + timeout: 5000 # Timeout (in ms) for all Playwright operations. Default: 5000 + pw_start: true # Start Playwright server (proxy to CodeceptJS) automatically. Set to `false` and run the server manually in case the server doesn't start. + pw_server: http://localhost:8191 # Url of Playwright server. Default: http://localhost:8191 + pw_debug: false # Print Playwright server debug information. Default: false + video: true # Save video on fail + trace: true # Save stack traces on fail ``` -Most common config values are: - -* `url`: Base url to open pages from -* `browser`: Either `chromium`, `firefox`, `webkit` -* `show` (default: `true`): Show the browser or run tests in headless mode -* `timeout` (default: `5000`): Timeout (in ms) for all Playwright operations -* `pw_start` (default: `true`): Start Playwright server (proxy to CodeceptJS) automatically. Set to `false` and run the server manually in case the server doesn't start. -* `pw_server` (default: `http://localhost:8191`): Url of Playwright server -* `pw_debug` (default: `false`): Print Playwright server debug information -* `video`: Save video on fail -* `trace`: Save stack traces on fail - -More configuration options are is listed on [CodeceptJS Playwright page](https://codecept.io/helpers/Playwright/#configuration) +More configuration options are listed on [CodeceptJS Playwright page](https://codecept.io/helpers/Playwright/#configuration) > [!Tip] -> This module is designed as drop-in WebDriver module replacement, you can change `WebDriver` to `Playwright` in your tests and try how it works! +> If you're switching from WebDriver, just change `WebDriver` to `Playwright` and see how it works! ## Usage From 0616f5b648d5581c9fbdc2b23e3cab0f6ec44af4 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 22 Sep 2024 13:26:39 +0200 Subject: [PATCH 4/4] Update Readme.md --- Readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 3ad985f..110af4e 100644 --- a/Readme.md +++ b/Readme.md @@ -34,7 +34,7 @@ composer require codeception/module-playwright --dev ## Configuration -Enable the module in `codeception.yml`: +Enable the module in `Acceptance.suite.yml`: ```yaml modules: @@ -47,6 +47,8 @@ modules: pw_start: true # Start Playwright server (proxy to CodeceptJS) automatically. Set to `false` and run the server manually in case the server doesn't start. pw_server: http://localhost:8191 # Url of Playwright server. Default: http://localhost:8191 pw_debug: false # Print Playwright server debug information. Default: false + + # Not implemented yet: video: true # Save video on fail trace: true # Save stack traces on fail ```