Skip to content

Commit

Permalink
Add browser M1/M2 Macs Docker steps
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Dec 4, 2023
1 parent 8c788a4 commit ebc8724
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/sources/next/using-k6-browser/running-browser-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,30 @@ To run a simple local script:

{{% /admonition %}}

3. Optional Step: Running browser tests in Docker on M1/M2 Macs

1. Make sure you’re running [the latest Docker](https://docs.docker.com/engine/install/) version.

2. Update [Rosetta](https://en.wikipedia.org/wiki/Rosetta_(software)) and export an environment variable with the following:

```bash
$ export DOCKER_DEFAULT_PLATFORM=linux/amd64
$ softwareupdate --install-rosetta
```

3. Select VirtioFS in `Settings` > `General` > `VirtuoFS`.

4. Enable the Rosetta emulation in `Settings` > `Features in development` > `Use Rosetta for x86/amd64 emulation on Apple Silicon`.

5. Restart Docker

6. Run the browser image with the following command (adds the `--platform` flag):

```bash
$ docker run --rm -i --platform linux/amd64 -v $(pwd):/home/k6/screenshots -e K6_BROWSER_HEADLESS=false grafana/k6:master-with-browser run - <script.js
```


## Interact with elements on your webpage

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](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator) object, which you can later use to interact with the element.
Expand Down

0 comments on commit ebc8724

Please sign in to comment.