Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add browser M1/M2 Macs Docker steps #1437

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
inancgumus marked this conversation as resolved.
Show resolved Hide resolved

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

3. Select VirtuoFS 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
Loading