Skip to content

Commit 01edd6f

Browse files
authored
Merge pull request #1269 from grafana/add-instructions-k6-browser-docker
add instructions on how to run k6 browser tests using Docker
2 parents 74f3e3b + 34b24e0 commit 01edd6f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/data/markdown/translated-guides/en/01 Get started/02 Installation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ Alternatively, you can download and run [the latest official installer](https://
5656
docker pull grafana/k6
5757
```
5858

59+
We also have a separate image you can use with `chromium` installed to run k6 browser tests.
60+
61+
```bash
62+
docker pull grafana/k6:master-with-browser
63+
```
64+
5965
## Download the k6 binary
6066

6167
Our [GitHub Releases page](https://github.com/grafana/k6/releases) has a standalone binary for all platforms. After downloading and extracting the archive for your platform, place the `k6` or `k6.exe` binary in your `PATH` to run `k6` from any location.

src/data/markdown/translated-guides/en/03 Using k6 browser/02 Running browser tests.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,20 @@ To run a simple local script:
5858

5959
2. Then, run the test on your terminal with this command:
6060

61-
<CodeGroup labels={["Bash", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
61+
<CodeGroup labels={["Bash", "Docker", "Windows: CMD", "Windows: PowerShell"]} lineNumbers={[false]}>
6262

6363
```bash
6464
$ K6_BROWSER_ENABLED=true k6 run script.js
6565
```
6666

67+
```bash
68+
# When using the `k6:master-with-browser` Docker image, you need to add `--cap-add=SYS_ADMIN`
69+
# to grant further system permissions on the host for the Docker container.
70+
# There is also no need to set the K6_BROWSER_ENABLED variable explicitly since this is already
71+
# defined in the Dockerfile.
72+
docker run --rm -i --cap-add=SYS_ADMIN grafana/k6:master-with-browser run - <script.js
73+
```
74+
6775
```bash
6876
C:\k6> set "K6_BROWSER_ENABLED=true" && k6 run script.js
6977
```
@@ -74,6 +82,12 @@ PS C:\k6> $env:K6_BROWSER_ENABLED=true ; k6 run script.js
7482

7583
</CodeGroup>
7684

85+
<Blockquote mod="note" title="">
86+
87+
When using Docker to run k6 browser tests, make sure you have pulled the correct image with Chromium built-in. See [k6 Installation via Docker](/get-started/installation/#docker) for more information.
88+
89+
</Blockquote>
90+
7791
## Interact with elements on your webpage
7892

7993
You can use `page.locator()` and pass in the element's selector you want to find on the page. `page.locator()` will create and return a [Locator](/javascript-api/k6-experimental/browser/locator/) object, which you can later use to interact with the element.
@@ -174,7 +188,7 @@ To run a browser-level and protocol-level test concurrently, you can use [scenar
174188

175189
Keep in mind that there is an additional performance overhead when it comes to spinning up a browser VU and that the resource usage will depend on the system under test.
176190

177-
</Blockquote>
191+
</Blockquote>
178192

179193
<CodeGroup labels={["script.js"]} lineNumbers={[true]}>
180194

0 commit comments

Comments
 (0)