You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Playwright offers better auto-waiting, a more intuitive locator-based API, and built-in debugging tools like trace viewer and inspector.
Puppeteer's auto-download of Chrome via postinstall scripts poses security risks.
Key changes:
- Add "sf browserforce playwright" wrapper command
- Use locators instead of selectors and eliminate evaluate() calls
- Leverage "await using" for automatic page cleanup
- Enable trace capture via BROWSERFORCE_TRACE
- Increase viewport to 1280x1536 to reduce scrolling
- Re-enable Slack and UserAccessPolicies tests
Huge kudos to @itkevin for initiating this migration and providing documentation!
Closes#706
Co-authored-by: Kevin Lindecke <kevin@lindecke.co>
BREAKING CHANGE: Puppeteer has been replaced with Playwright.
Browsers are no longer installed automatically.
Install a browser explicitly:
```shell
sf browserforce playwright -- install chromium
```
Or configure an existing browser via any of these environment variables:
```shell
BROWSERFORCE_BROWSER_CHANNEL="chrome"
BROWSERFORCE_BROWSER_EXECUTABLE_PATH="/usr/bin/google-chrome"
CHROME_BIN="/usr/bin/google-chrome"
```
@@ -133,8 +134,8 @@ This allows to run multiple actions (from multiple plugins) using a single confi
133
134
134
135
Plugins are written in [Typescript](https://www.typescriptlang.org), just like `sf` and most of the available sf plugins.
135
136
136
-
[Puppeteer](https://pptr.dev) is being used as a library for browser automation.
137
-
If you need more inspiration regarding Puppeteer, checkout [this curated list](https://github.com/transitive-bullshit/awesome-puppeteer) of awesome Puppeteer resources.
137
+
[Playwright](https://playwright.dev) is being used as a library for browser automation.
138
+
If you need more inspiration regarding Playwright, checkout the [official documentation](https://playwright.dev/docs/intro) and our [best practices guide](./docs/PLAYWRIGHT.md).
138
139
139
140
The simplified browserforce plugin lifecycle can be described as follows
140
141
@@ -196,3 +197,41 @@ for i in {1..7}; do npm run test:e2e -- -g "AdminsCanLogInAsAnyUser"; done
196
197
## Debugging
197
198
198
199
The [Salesforce CLI Plug-In Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_debug.htm) describes debugging sfdx plugins using VS Code very well.
200
+
201
+
### Playwright Debugging and Tracing
202
+
203
+
When developing or debugging Playwright-based plugins, you have several tools at your disposal:
204
+
205
+
#### Visual Debugging
206
+
207
+
To see the browser while tests run:
208
+
209
+
```bash
210
+
BROWSERFORCE_HEADLESS=false npm run test:e2e -- --grep "YourPlugin"
211
+
```
212
+
213
+
To slow down execution for better observation (value in milliseconds):
214
+
215
+
```bash
216
+
BROWSERFORCE_SLOWMO=1000 npm run test:e2e -- --grep "YourPlugin"
217
+
```
218
+
219
+
#### Playwright Tracing
220
+
221
+
Playwright tracing captures detailed information about test execution including screenshots, DOM snapshots, network activity, and console logs. This is invaluable for debugging test failures.
222
+
223
+
To generate a trace for a specific test:
224
+
225
+
```bash
226
+
BROWSERFORCE_TRACE=true npm run test:e2e -- --grep "YourPlugin"
227
+
```
228
+
229
+
After the test completes, a trace file will be saved with a timestamp (e.g., `trace-2025-11-23T19-00-00-000Z.zip`).
This opens an interactive viewer in your browser where you can step through each action, view screenshots and DOM snapshots, inspect network requests, and review console logs.
> Since v6 we're using Playwright instead of Puppeteer. Please see the [release notes](https://github.com/amtrack/sfdx-browserforce-plugin/releases) for migration instructions.
9
+
7
10
✅ Most settings in the Salesforce Setup Menu are represented as [Settings](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_settings.htm) in the Metadata API.
8
11
9
12
For example, the highlighted checkbox "Show View Hierarchy link on account pages" in Account Settings is indeed represented in the Metadata `AccountSettings` as `showViewHierarchyLink`.
- 🔧 configuration using JSON Schema (similar to the [Scratch Org Definition Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm))
56
59
- 🧠 idempotency of the `apply` command only applies what's necessary and allows re-execution (concept similar to [terraform](https://www.terraform.io/docs/commands/apply.html))
57
-
- 🏎️ browser automation powered by Puppeteer and "Chrome for Testing", [learn more about Puppeteer and Browserforce](#puppeteer)
60
+
- 🏎️ browser automation powered by Playwright, [learn more about Playwright and Browserforce](#playwright)
58
61
59
62
## Supported Browserforce Settings
60
63
@@ -77,79 +80,165 @@ But there's more:
77
80
78
81
## Installation
79
82
80
-
There are several different methods to install `sfdx-browserforce-plugin`:
81
-
82
83
```shell
83
-
# as an sf plugin globally
84
84
sf plugins install sfdx-browserforce-plugin
85
+
```
85
86
86
-
# or standalone globally
87
-
npm install --global sfdx-browserforce-plugin
87
+
> [!IMPORTANT]
88
+
> Playwright does not come with a browser automatically
88
89
89
-
# or standalone locally (as a dependency in your Node.js project)
90
-
npm install --save-dev sfdx-browserforce-plugin
91
-
```
90
+
You might need to install a browser explicitly or configure Browserforce to use an existing browser.
92
91
93
-
## Usage
92
+
> [!TIP]
93
+
> If you're using Browserforce on GitHub Actions with the `ubuntu-latest` (v24) Docker image, we can use the preinstalled Google Chrome automatically.
94
+
> No further configuration and installation needed, because the `CHROME_BIN` environment variable is already set.
94
95
95
-
Depending on your choice of installation, you can find the `browserforce` namespace:
96
+
### Option 1: Install a browser using our Playwright wrapper command
96
97
97
98
```shell
98
-
# globally in the sf cli
99
-
sf browserforce
99
+
sf browserforce playwright -- install chromium
100
+
```
101
+
102
+
> [!IMPORTANT]
103
+
> The two hyphens `--` are intentional and separate the sf command from the arguments to be passed to the playwright executable.
104
+
105
+
### Option 2: Configure Browserforce to use an existing browser
100
106
101
-
# globally in the sfdx-browserforce-plugin executable
102
-
sfdx-browserforce-plugin browserforce
107
+
You can use any of the following environment variables:
103
108
104
-
# locally in the sfdx-browserforce-plugin executable (npx is awesome!)
We use [Playwright](https://playwright.dev/) for browser automation.
217
+
218
+
For more information on browser automation best practices, see the [Playwright documentation](./docs/PLAYWRIGHT.md).
219
+
220
+
## Alternative Installation
221
+
222
+
You can also install the `sfdx-browserforce-plugin` NPM package without `sf`. The package exports a `sfdx-browserforce-plugin` executable:
223
+
224
+
Example:
225
+
226
+
```shell
227
+
npm install --save-dev sfdx-browserforce-plugin
228
+
npx sfdx-browserforce-plugin browserforce -h
148
229
```
149
230
150
231
## Troubleshooting
151
232
152
-
- The installation is triggered via the `postinstall` hook of npm/yarn. If you've disabled running scripts with npm (`--ignore-scripts` or via config file), it will not download the browser.
233
+
If no browser is installed or launching fails, you'll get an error message from Playwright with a suggestion.
234
+
235
+
Typically this will guide you to install a browser.
236
+
If you've installed sfdx-browserforce-plugin using `sf`, you can replace the following:
0 commit comments