Skip to content

Commit 01a9ba5

Browse files
DavertMikclaude
andcommitted
docs: one section per engine in alternative browsers guide
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7a5d286 commit 01a9ba5

1 file changed

Lines changed: 111 additions & 85 deletions

File tree

‎docs/alternative-browsers.md‎

Lines changed: 111 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -6,149 +6,175 @@ title: Alternative Browser Engines
66
# Alternative Browser Engines
77

88
::: warning Experimental
9-
The `Lightpanda`, `Obscura` and `Kitesurf` helpers are experimental. Keep a Playwright or WebDriver job for compatibility-critical tests.
9+
The `Obscura`, `Lightpanda` and `Kitesurf` helpers are experimental. Keep a Playwright or WebDriver job for compatibility-critical tests.
1010
:::
1111

12-
Your tests stay the same. `I.amOnPage`, `I.click`, `I.fillField`, `I.see`, `I.seeElement` and the rest of the `I.*` web API work on every engine below; only the helper in the config changes.
12+
Playwright drives full Chromium, Firefox and WebKit: the most accurate way to test what users see, at the cost of a heavy browser per worker. Alternative engines trade part of that accuracy for speed, a small footprint, or cloud scale. They are a good fit for functional tests (text appears, form submits, redirect happens, cookie is set) and a poor one for anything visual.
1313

14-
| Engine | What it is | Screenshots | Runs on |
15-
|---|---|---|---|
16-
| [Lightpanda](https://lightpanda.io) | headless browser built for automation, nothing painted | no | Linux, macOS |
17-
| [Obscura](https://github.com/h4ckf0r0day/obscura) | lightweight browser with its own rendering engine | yes | Linux, macOS, Windows |
18-
| [Kitesurf](https://blog.cloudflare.com/kitesurf/) | Cloudflare's browser in the cloud | yes | Cloudflare |
14+
Your tests do not change. `I.amOnPage`, `I.click`, `I.fillField`, `I.see`, `I.seeElement` and the rest of the `I.*` web API work the same; you only swap the helper in the config. All engines below speak Chrome DevTools Protocol, so there is no `npx playwright install` step.
1915

20-
All three speak Chrome DevTools Protocol. There is no `npx playwright install` step: Lightpanda and Obscura are single binaries, Kitesurf is a cloud service.
16+
Compared to Playwright, none of them supports iframes (`switchTo`), multiple tabs, popups, `dragAndDrop`, `moveCursorTo`, clipboard actions, or Playwright-only APIs such as `usePlaywrightTo` and `mockRoute`. Tag scenarios that need those and skip them on the alternative engine:
2117

22-
## When to use which
18+
```sh
19+
npx codeceptjs run --grep @playwright-only --invert
20+
```
2321

24-
- **Lightpanda**: fastest start and smallest memory footprint. Functional tests that never need a screenshot.
25-
- **Obscura**: lightweight like Lightpanda, but renders, so screenshots and failure screenshots work.
26-
- **Kitesurf**: as many parallel browsers as you have workers, with nothing running on your machine.
27-
- **Stay on Playwright** for visual checks, iframes, multiple tabs, drag-and-drop, network mocking, and Firefox or WebKit.
22+
To see which `I.*` actions the configured engine supports:
2823

29-
## Install
24+
```sh
25+
npx codeceptjs list
26+
```
3027

31-
Follow the official instructions, then put the binary on `PATH`:
28+
## Obscura
3229

33-
- **Lightpanda**: [lightpanda.io/docs/open-source/installation](https://lightpanda.io/docs/open-source/installation)
34-
- **Obscura**: [github.com/h4ckf0r0day/obscura](https://github.com/h4ckf0r0day/obscura#installation)
35-
- **Kitesurf**: [Cloudflare Browser Run](https://developers.cloudflare.com/browser-run/), then export `CF_ACCOUNT_ID` and `CF_API_TOKEN`
30+
[Obscura](https://github.com/h4ckf0r0day/obscura) is a lightweight open-source browser with a real V8 engine and its own rendering engine, distributed as a single binary for Linux, macOS and Windows. Unlike Lightpanda it renders: layout, visibility checks, screenshots and the `screencast` plugin work.
3631

37-
## Configure
32+
Limitations:
3833

39-
Pick the engine with an environment variable, so one config serves every engine and Playwright stays the default:
34+
- Its CSS engine is new: some computed styles differ from Chromium, so `grabCssPropertyFrom` and `seeCssPropertiesOnElements` can disagree with Playwright.
35+
- `click` is always dispatched as a DOM event, not a mouse event at coordinates.
36+
- `-no-render` builds have no layout: no visibility checks and no screenshots.
4037

41-
```js
42-
// codecept.conf.js
43-
const url = 'http://localhost:3000'
38+
### Setup
4439

45-
const engines = {
46-
playwright: { Playwright: { url, browser: 'chromium' } },
47-
lightpanda: { Lightpanda: { url } },
48-
obscura: { Obscura: { url } },
49-
kitesurf: { Kitesurf: { url: 'https://staging.myapp.com' } },
50-
}
40+
Install Obscura following the [official instructions](https://github.com/h4ckf0r0day/obscura#installation) and put `obscura` on `PATH`. Then enable the helper:
5141

42+
```js
43+
// codecept.conf.js
5244
export const config = {
53-
tests: './tests/*_test.js',
54-
output: './output',
55-
helpers: engines[process.env.ENGINE || 'playwright'],
45+
helpers: {
46+
Obscura: {
47+
url: 'http://localhost:3000',
48+
},
49+
},
5650
}
5751
```
5852

59-
There is nothing to start by hand. Lightpanda and Obscura are launched on a free port before the first test and stopped after the last one, the way Playwright manages Chromium.
53+
If the binary is not on `PATH`, set `binaryPath` in the config or the `OBSCURA_PATH` environment variable.
6054

61-
If the binary is not on `PATH`, point the helper at it, like Playwright's `executablePath`:
55+
### Usage
6256

63-
```js
64-
Lightpanda: { url, binaryPath: './bin/lightpanda' }
57+
```sh
58+
npx codeceptjs run
6559
```
6660

67-
Or set it per machine with an environment variable:
61+
The helper starts `obscura serve` on a free port before the first test and stops it after the last one, like Playwright manages Chromium. Each worker gets its own instance:
6862

6963
```sh
70-
LIGHTPANDA_PATH=/opt/lightpanda/lightpanda npx codeceptjs run
64+
npx codeceptjs run-workers 8
7165
```
7266

73-
The helper checks `binaryPath`, then `LIGHTPANDA_PATH` (`OBSCURA_PATH` for Obscura), then `PATH`. Relative paths resolve from the directory you run `npx codeceptjs` in.
74-
75-
## Run
67+
To connect to an Obscura you started yourself, set `endpoint`; the helper then never starts or stops it:
7668

7769
```sh
78-
ENGINE=lightpanda npx codeceptjs run
70+
obscura serve --port 9222 --allow-private-network --allow-file-access
7971
```
8072

81-
Each worker starts its own browser on its own port:
82-
83-
```sh
84-
ENGINE=lightpanda npx codeceptjs run-workers 8
73+
```js
74+
Obscura: {
75+
url: 'http://localhost:3000',
76+
endpoint: 'http://127.0.0.1:9222',
77+
}
8578
```
8679

87-
See which `I.*` actions the engine supports:
80+
All options: [Obscura helper reference](/helpers/Obscura).
8881

89-
```sh
90-
ENGINE=lightpanda npx codeceptjs list
91-
```
82+
## Lightpanda
83+
84+
[Lightpanda](https://lightpanda.io) is an open-source headless browser built from scratch for automation. It runs your app's JavaScript in V8 but never paints anything, which makes it start in milliseconds and use a fraction of Chromium's memory. It computes enough layout for `seeElement`, `waitForVisible` and other visibility checks.
9285

93-
## Exclude what an engine cannot do
86+
Limitations:
9487

95-
Most functional tests pass unchanged. These Playwright features do not carry over:
88+
- No screenshots: `saveScreenshot`, failure screenshots and the `screencast` plugin do not work.
89+
- No scrolling: `scrollTo` and `scrollPageToBottom` have no effect.
90+
- No coordinate input: `clickXY` does not work.
91+
- Computed styles cover `display`, `visibility` and `opacity`; other CSS properties are unreliable.
92+
- Some rich text editors (TinyMCE, Trix, Monaco) never finish loading.
93+
- Linux and macOS only; on Windows use WSL2.
94+
- Licensed under AGPL-3.0. It runs as a separate process, so it does not affect the license of your tests.
9695

97-
| Feature | Lightpanda | Obscura |
98-
|---|---|---|
99-
| `saveScreenshot`, failure screenshots, `screencast` plugin | no | yes |
100-
| `seeElement`, `waitForVisible` and other visibility checks | yes | yes |
101-
| `switchTo` (iframes), new tabs, popups | no | no |
102-
| `dragAndDrop`, `moveCursorTo` | no | no |
103-
| `clickXY` | no | yes |
104-
| `scrollTo`, `scrollPageToBottom` | no effect | yes |
105-
| `grabCssPropertyFrom`, `seeCssPropertiesOnElements` | `display`, `visibility`, `opacity` only | most properties |
106-
| clipboard actions | no | no |
107-
| `usePlaywrightTo`, `mockRoute`, downloads | no | no |
96+
### Setup
10897

109-
Tag the scenarios that need a full browser:
98+
Install Lightpanda following the [official instructions](https://lightpanda.io/docs/open-source/installation) and put `lightpanda` on `PATH`. Then enable the helper:
11099

111100
```js
112-
Scenario('checkout matches the design @visual', ({ I }) => {
113-
I.amOnPage('/checkout')
114-
I.saveScreenshot('checkout.png')
115-
})
101+
// codecept.conf.js
102+
export const config = {
103+
helpers: {
104+
Lightpanda: {
105+
url: 'http://localhost:3000',
106+
},
107+
},
108+
}
116109
```
117110

118-
And skip them on the lightweight engine:
111+
If the binary is not on `PATH`, set `binaryPath` in the config or the `LIGHTPANDA_PATH` environment variable.
112+
113+
### Usage
119114

120115
```sh
121-
ENGINE=lightpanda npx codeceptjs run --grep @visual --invert
116+
npx codeceptjs run
122117
```
123118

124-
## Run in CI
119+
The helper starts `lightpanda serve` on a free port with telemetry turned off, and stops it after the last test. Each worker gets its own instance:
125120

126-
Install the binary in a step before the tests, and point the helper at it with `LIGHTPANDA_PATH` (or `OBSCURA_PATH`) if it is not on `PATH`. Run the lightweight engine as a fast first job and keep Playwright for the full run.
121+
```sh
122+
npx codeceptjs run-workers 8
123+
```
127124

128-
## Connect to a running browser
125+
To connect to a Lightpanda you started yourself, set `endpoint`; the helper then never starts or stops it:
129126

130-
To use a browser you started yourself (a container, a remote host), set `endpoint`. The helper then only connects and never starts or stops anything:
127+
```sh
128+
LIGHTPANDA_DISABLE_TELEMETRY=true lightpanda serve --host 127.0.0.1 --port 9222
129+
```
131130

132131
```js
133-
Lightpanda: { url, endpoint: 'http://127.0.0.1:9222' }
132+
Lightpanda: {
133+
url: 'http://localhost:3000',
134+
endpoint: 'http://127.0.0.1:9222',
135+
}
134136
```
135137

136-
Start Lightpanda yourself with telemetry turned off:
138+
All options: [Lightpanda helper reference](/helpers/Lightpanda).
139+
140+
## Kitesurf
141+
142+
[Kitesurf](https://blog.cloudflare.com/kitesurf/) is Cloudflare's browser running on Cloudflare Workers, with a real layout and rendering pipeline. Sessions start in about a second and nothing runs on your machine, so the number of parallel browsers is limited only by how far your suite splits.
143+
144+
Limitations:
145+
146+
- Cloud only, currently a free beta.
147+
- The browser cannot reach `localhost`: test a deployed environment or expose your app with a tunnel such as `cloudflared tunnel --url http://localhost:3000`.
148+
- The `screencast` plugin is untested.
149+
150+
### Setup
151+
152+
Enable [Cloudflare Browser Run](https://developers.cloudflare.com/browser-run/) and create an API token with the **Browser Rendering → Edit** permission. Export the credentials:
137153

138154
```sh
139-
LIGHTPANDA_DISABLE_TELEMETRY=true lightpanda serve --host 127.0.0.1 --port 9222
155+
export CF_ACCOUNT_ID=your-account-id
156+
export CF_API_TOKEN=your-api-token
140157
```
141158

142-
Start Obscura yourself with access to local apps and files:
159+
Then enable the helper:
143160

144-
```sh
145-
obscura serve --port 9222 --allow-private-network --allow-file-access
161+
```js
162+
// codecept.conf.js
163+
export const config = {
164+
helpers: {
165+
Kitesurf: {
166+
url: 'https://staging.myapp.com',
167+
},
168+
},
169+
}
146170
```
147171

148-
Without `endpoint` and without a binary, the helper attaches to whatever already answers on `http://127.0.0.1:9222`.
172+
### Usage
173+
174+
Every worker opens its own cloud session:
149175

150-
## Good to know
176+
```sh
177+
npx codeceptjs run-workers 16
178+
```
151179

152-
- The helper starts Lightpanda with its telemetry turned off.
153-
- Lightpanda is AGPL-3.0 and Obscura is Apache-2.0. Both run as separate processes, so neither affects the license of your tests.
154-
- All options are in the helper references: [Lightpanda](/helpers/Lightpanda), [Obscura](/helpers/Obscura), [Kitesurf](/helpers/Kitesurf).
180+
All options: [Kitesurf helper reference](/helpers/Kitesurf).

0 commit comments

Comments
 (0)