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 tests can be executed to run on your CI environments. To simplify this, we have created sample configurations for common CI providers that can be used to bootstrap your setup.
Broadly, configuration on CI involves **ensuring system dependencies** are in place, **installing Playwright and browsers** (typically with `npm install`), and **running tests** (typically with `npm test`). Windows and macOS build agents do not require any additional system dependencies. Linux build agents can require additional dependencies, depending on the Linux distribution.
15
20
16
-
## GitHub Actions
21
+
## CI configurations
22
+
23
+
### GitHub Actions
17
24
18
25
The [Playwright GitHub Action](https://github.com/microsoft/playwright-github-action) can be used to run Playwright tests on GitHub Actions.
19
26
@@ -26,24 +33,126 @@ steps:
26
33
27
34
We run [our tests](/.github/workflows/tests.yml) on GitHub Actions, across a matrix of 3 platforms (Windows, Linux, macOS) and 3 browsers (Chromium, Firefox, WebKit).
28
35
29
-
## Docker
36
+
### Docker
30
37
31
38
We have a [pre-built Docker image](docker/README.md) which can either be used directly, or as a reference to update your existing Docker definitions.
32
39
33
-
## Azure Pipelines
40
+
#### Tips
41
+
1. By default, Docker runs a container with a `/dev/shm` shared memory space 64MB.
42
+
This is [typically too small](https://github.com/c0b/chrome-in-docker/issues/1) for Chromium
43
+
and will cause Chromium to crash when rendering large pages. To fix, run the container with
44
+
`docker run --shm-size=1gb`to increase the size of `/dev/shm`. Since Chromium 65, this is no
45
+
longer necessary. Instead, launch the browser with the `--disable-dev-shm-usage` flag:
This will write shared memory files into `/tmp` instead of `/dev/shm`. See
54
+
[crbug.com/736452](https://bugs.chromium.org/p/chromium/issues/detail?id=736452) for more details.
55
+
1. Using `--ipc=host` is also recommended when using Chromium—without it Chromium can run out of memory
56
+
and crash. Learn more about this option in [Docker docs](https://docs.docker.com/engine/reference/run/#ipc-settings---ipc).
57
+
1. Seeing other weird errors when launching Chromium? Try running your container
58
+
with `docker run --cap-add=SYS_ADMIN` when developing locally. Since the Dockerfile
59
+
adds a `pwuser` user as a non-privileged user, it may not have all the necessary privileges.
60
+
1. [dumb-init](https://github.com/Yelp/dumb-init) is worth checking out if you're
61
+
experiencing a lot of zombies Chromium processes sticking around. There's special
62
+
treatment for processes with PID=1, which makes it hard to terminate Chromium
63
+
properly in some cases (e.g. in Docker).
64
+
65
+
### Azure Pipelines
34
66
35
67
For Windows or macOS agents, no additional configuration required, just install Playwright and run your tests.
36
68
37
69
For Linux agents, refer to [our Docker setup](docker/README.md) to see additional dependencies that need to be installed.
38
70
39
-
## Travis CI
71
+
### Travis CI
40
72
41
73
We run our tests on Travis CI over a Linux agent (Ubuntu 18.04). Use our [Travis configuration](/.travis.yml) to see list of additional dependencies to be installed.
42
74
43
-
## CircleCI
75
+
#### Tips
76
+
- [User namespace cloning](http://man7.org/linux/man-pages/man7/user_namespaces.7.html) should be enabled to support proper sandboxing
77
+
- [xvfb](https://en.wikipedia.org/wiki/Xvfb) should be launched in order to run Chromium in non-headless mode (e.g. to test Chrome Extensions)
78
+
79
+
To sum up, your `.travis.yml` might look like this:
80
+
81
+
```yml
82
+
language: node_js
83
+
dist: bionic
84
+
addons:
85
+
apt:
86
+
packages:
87
+
# These are required to run webkit
88
+
- libwoff1
89
+
- libopus0
90
+
- libwebp6
91
+
- libwebpdemux2
92
+
- libenchant1c2a
93
+
- libgudev-1.0-0
94
+
- libsecret-1-0
95
+
- libhyphen0
96
+
- libgdk-pixbuf2.0-0
97
+
- libegl1
98
+
- libgles2
99
+
- libevent-2.1-6
100
+
- libnotify4
101
+
- libxslt1.1
102
+
- libvpx5
103
+
# This is required to run chromium
104
+
- libgbm1
105
+
106
+
# allow headful tests
107
+
before_install:
108
+
# Enable user namespace cloning
109
+
- "sysctl kernel.unprivileged_userns_clone=1"
110
+
# Launch XVFB
111
+
- "export DISPLAY=:99.0"
112
+
- "sh -e /etc/init.d/xvfb start"
113
+
```
114
+
115
+
### CircleCI
116
+
117
+
We run our tests on CircleCI, with our [pre-built Docker image](docker/README.md). Use our [CircleCI configuration](/.circleci/config.yml) to create your own. Running Playwright smoothly on CircleCI requires the following steps:
118
+
119
+
1. Use the pre-built [Docker image](docker/README.md) in your config like so:
120
+
121
+
```yaml
122
+
docker:
123
+
- image: aslushnikov/playwright:bionic
124
+
environment:
125
+
NODE_ENV: development # Needed if playwright is in `devDependencies`
126
+
```
127
+
128
+
1. If you’re using Playwright through Jest, then you may encounter an error spawning child processes:
129
+
130
+
```
131
+
[00:00.0] jest args: --e2e --spec --max-workers=36
132
+
Error: spawn ENOMEM
133
+
at ChildProcess.spawn (internal/child_process.js:394:11)
134
+
```
135
+
136
+
This is likely caused by Jest autodetecting the number of processes on the entire machine (`36`) rather than the number allowed to your container (`2`). To fix this, set `jest --maxWorkers=2` in your test command.
137
+
138
+
### AppVeyor
139
+
140
+
We run our tests on Windows agents in AppVeyor. Use our [AppVeyor configuration](/.appveyor.yml) to create your own.
141
+
142
+
## Debugging browser launches
143
+
144
+
Playwright supports the `DEBUG` environment variable to output debug logs during execution. Setting it to `pw:browser*` is helpful while debugging `Error: Failed to launch browser` errors.
145
+
146
+
```
147
+
DEBUG=pw:browser* npm run test
148
+
```
149
+
150
+
## Caching browsers
44
151
45
-
We run our tests on CircleCI, with our [pre-built Docker image](docker/README.md). Use our [CircleCI configuration](/.circleci/config.yml) to create your own.
152
+
By default, Playwright installs browser binaries in the following directories. This behavior can be [customized with environment variables](installation.md).
46
153
47
-
## AppVeyor
154
+
- `%USERPROFILE%\AppData\Local\ms-playwright`on Windows
155
+
- `~/Library/Caches/ms-playwright`on MacOS
156
+
- `~/.cache/ms-playwright`on Linux
48
157
49
-
We run our tests on Windows agents in AppVeyor. Use our [AppVeyor configuration](/.appveyor.yml) to create your own.
158
+
These locations are not covered by typical CI configurations, which cache the project `node_modules` or the [npm-cache directory](https://docs.npmjs.com/cli-commands/cache.html). To cache the browser binaries between CI runs, cache this location in your CI configuration, against a hash of the Playwright version.
Copy file name to clipboardExpand all lines: docs/emulation.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,14 @@ Playwright allows overriding various parameters of the device where the browser
9
9
10
10
Most of these parameters are configured during the browser context construction, but some of them such as viewport size can be changed for individual pages.
Copy file name to clipboardExpand all lines: docs/selectors.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,12 @@ Playwright supports multiple selector engines used to query elements in the web
4
4
5
5
Selector can be used to obtain `ElementHandle` (see [page.$()](api.md#pageselector) for example) or shortcut element operations to avoid intermediate handle (see [page.click()](api.md#pageclickselector-options) for example).
Selector is a string that consists of one or more clauses separated by `>>` token, e.g. `clause1 >> clause2 >> clause3`. When multiple clauses are present, next one is queried relative to the previous one's result.
0 commit comments