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
* Adds the playwright command
* update to new syntax
* Moved Playwright command to subpage of measuring websites
---------
Co-authored-by: Arne Tarara <[email protected]>
Copy file name to clipboardExpand all lines: content/en/docs/measuring/measuring-websites.md
+103-2Lines changed: 103 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ To isolate this as best as possible GMT orchestrates a reverse proxy, warms up t
15
15
16
16
**Warning:** Measuring websites is very tricky! GMT shaves off some of the caveats by using reverse proxys and cache pre-loading to make results more reliable. Since measurement load times are in milliseconds range you must have [Metric Providers]({{< relref "/docs/measuring/metric-providers/" >}}) with very high *sampling_rates* connected. **2ms** is a good value. Also website measurements are really only realiable in a [controlled cluster]({{< relref "/docs/cluster/" >}}) with [accuracy control]({{< relref "/docs/cluster/accuracy-control" >}}).
17
17
18
-
####Quick website measuring
18
+
## Quick website measuring
19
19
20
20
Since measuring websites is so common GMT comes with a quick measurement function for that.
21
21
@@ -27,8 +27,109 @@ It will download the needed containers, setup them up and run the measurement. O
27
27
28
28
Bonus tip: If you apply `--quick` to the `run-template.sh` call the measurement is quicker for debugging purposes. However results will be not as reliable. Use only for debugging!
29
29
30
-
####Trying out our hosted service
30
+
## Trying out our hosted service
31
31
32
32
We operate [website-tester.green-coding.io](https://website-tester.green-coding.io) as a simple demo vertical that uses the underlying [Green Metrics Tool Cluster Hosted Service →]({{< relref "/docs/measuring/measuring-service" >}}).
33
33
34
34
Check it out if you do not feel like installing the GMT and just want to get carbon and energy info on a single page.
35
+
36
+
## Crafting your own flows with Playwright commands
37
+
38
+
The Green Metrics Tool supports **Playwright** as a first-class command type in the `usage_scenario.yml`.
39
+
[Playwright](https://playwright.dev/) is a popular framework for end-to-end browser automation. With this integration, you can run browser-based user journeys directly inside your usage scenarios without maintaining a separate Playwright script file.
40
+
41
+
---
42
+
43
+
### Simplified Setup with GMT Helper
44
+
45
+
Getting started with Playwright is easy using the `!include-gmt-helper`. By including `gmt-playwright-v1.0.0.yml`, the Green Metrics Tool automatically:
46
+
47
+
1. Configures the Playwright service container (`gmt-playwright-nodejs`) with the official Microsoft Playwright image.
48
+
2. Installs all necessary Playwright libraries.
49
+
3. Starts the Playwright browser and an IPC listener in the background.
50
+
51
+
To get started, add the following to your `usage_scenario.yml`:
52
+
53
+
```yaml
54
+
!include-gmt-helper: gmt-playwright-v1.0.0.yml
55
+
56
+
# Your flow can now use the gmt-playwright-nodejs container
This helper significantly simplifies your workflow by handling the setup for you.
68
+
69
+
---
70
+
71
+
### Defining Playwright Commands
72
+
73
+
As shown above, you can define steps of type `playwright` in your flow.
74
+
75
+
- `type: playwright`
76
+
Defines a Playwright step instead of a shell command.
77
+
- `container: gmt-playwright-nodejs`
78
+
This must match the container provided by the GMT Playwright helper.
79
+
- `command:`**[str]**
80
+
A JavaScript/TypeScript snippet that is executed via Playwright inside the container.
81
+
82
+
This allows you to inline browser interactions alongside other commands for fine-grained measurement.
83
+
84
+
---
85
+
86
+
### Caching with a Reverse Proxy
87
+
88
+
For scenarios where you want to cache browser requests to minimize network variability, use the `gmt-playwright-with-cache-v1.0.0.yml` helper. It sets up an additional `squid` reverse proxy service and configures Playwright to use it.
0 commit comments