Skip to content

Commit 7c95de5

Browse files
mdcruzka3de
authored andcommitted
document browserContext.addCookies()
1 parent 63ba8be commit 7c95de5

File tree

5 files changed

+121
-23
lines changed

5 files changed

+121
-23
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: 'addCookies()'
3+
excerpt: 'Clears context cookies.'
4+
---
5+
6+
Adds cookies into the `BrowserContext`. All pages within this context will have these cookies installed.
7+
8+
### Example
9+
10+
<CodeGroup labels={[]}>
11+
12+
```javascript
13+
import { chromium } from 'k6/experimental/browser';
14+
15+
export default async function () {
16+
const browser = chromium.launch();
17+
const context = browser.newContext();
18+
19+
context.addCookies([
20+
{
21+
name: 'myCookie',
22+
value: 'hello world',
23+
url: 'https://test.k6.io/',
24+
},
25+
]);
26+
27+
const page = context.newPage();
28+
await page.goto('https://test.k6.io/');
29+
}
30+
```
31+
32+
</CodeGroup>

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/02 BrowserContext/clearCookies.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,22 @@ This feature has **known issues**. For details, refer to
1111
</Blockquote>
1212

1313
Clears the `BrowserContext`'s cookies.
14+
15+
### Example
16+
17+
<CodeGroup labels={[]}>
18+
19+
```javascript
20+
import { chromium } from 'k6/experimental/browser';
21+
22+
export default async function () {
23+
const browser = chromium.launch();
24+
const context = browser.newContext();
25+
const page = context.newPage();
26+
27+
await page.goto('https://test.k6.io/');
28+
context.clearCookies();
29+
}
30+
```
31+
32+
</CodeGroup>

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/08 Locator/click--options--.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Mouse click on the chosen element.
3030

3131
</TableWithNestedRows>
3232

33-
### Example
33+
### Examples
3434

35-
<CodeGroup labels={[]}>
35+
<CodeGroup labels={["Click action without navigation"]}>
3636

3737
```javascript
3838
import { chromium } from 'k6/experimental/browser';
@@ -48,3 +48,23 @@ export default async function () {
4848
```
4949

5050
</CodeGroup>
51+
52+
When a click action results in a page navigation, remember to work with `Promise.all()` and `page.waitForNavigation()` to properly handle the asychronous operation.
53+
54+
<CodeGroup labels={["Click action with navigation"]}>
55+
56+
```javascript
57+
import { chromium } from 'k6/experimental/browser';
58+
59+
export default async function () {
60+
const browser = chromium.launch();
61+
const page = browser.newPage();
62+
63+
await page.goto('https://test.k6.io/');
64+
const messagesLink = page.locator('a[href="/my_messages.php"]');
65+
66+
await Promise.all([page.waitForNavigation(), messagesLink.click()]);
67+
}
68+
```
69+
70+
</CodeGroup>

src/data/markdown/translated-guides/en/03 Using k6 browser/01 Overview.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,34 @@ default ✓ [===============================] 1 VUs 00m01.9s/10m0s 1/1 iters,
8686

8787
✓ header
8888

89-
browser_dom_content_loaded.......: avg=7.31ms min=122µs med=5.59ms max=16.22ms p(90)=14.1ms p(95)=15.16ms
90-
browser_first_contentful_paint...: avg=16.8ms min=14.78ms med=16.8ms max=18.81ms p(90)=18.41ms p(95)=18.61ms
91-
browser_first_paint..............: avg=16.75ms min=14.73ms med=16.75ms max=18.78ms p(90)=18.37ms p(95)=18.58ms
92-
browser_loaded...................: avg=7.23ms min=1.13ms med=4.56ms max=16.01ms p(90)=13.72ms p(95)=14.87ms
93-
checks...........................: 100.00% ✓ 1 ✗ 0
94-
data_received....................: 5.8 kB 3.0 kB/s
95-
data_sent........................: 2.6 kB 1.3 kB/s
96-
http_req_connecting..............: avg=40.4ms min=0s med=0s max=202ms p(90)=121.2ms p(95)=161.59ms
97-
http_req_duration................: avg=117.6ms min=649µs med=96.27ms max=298.96ms p(90)=218.15ms p(95)=258.55ms
98-
http_req_receiving...............: avg=75.4ms min=0s med=94ms max=95ms p(90)=95ms p(95)=95ms
99-
http_req_sending.................: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
100-
http_req_tls_handshaking.........: avg=21.6ms min=0s med=0s max=108ms p(90)=64.8ms p(95)=86.39ms
101-
http_reqs........................: 5 2.568486/s
102-
iteration_duration...............: avg=1.94s min=1.94s med=1.94s max=1.94s p(90)=1.94s p(95)=1.94s
103-
iterations.......................: 1 0.513697/s
104-
vus..............................: 1 min=1 max=1
105-
vus_max..........................: 1 min=1 max=1
89+
browser_dom_content_loaded.............................: avg=63.74ms min=2.11ms med=21.66ms max=167.44ms p(90)=138.28ms p(95)=152.86ms
90+
browser_first_paint....................................: avg=72.62ms min=41.31ms med=72.62ms max=103.94ms p(90)=97.67ms p(95)=100.8ms
91+
browser_loaded.........................................: avg=63.16ms min=6.52ms med=15.98ms max=166.98ms p(90)=136.78ms p(95)=151.88ms
92+
checks.................................................: 100.00% ✓ 1 ✗ 0
93+
data_received..........................................: 5.8 kB 659 B/s
94+
data_sent..............................................: 2.6 kB 291 B/s
95+
http_req_connecting....................................: avg=48ms min=0s med=0s max=240ms p(90)=144ms p(95)=191.99ms
96+
http_req_duration......................................: avg=155.01ms min=3.09ms med=121.84ms max=405.52ms p(90)=294.59ms p(95)=350.05ms
97+
http_req_receiving.....................................: avg=92.6ms min=0s med=108ms max=138ms p(90)=127.2ms p(95)=132.6ms
98+
http_req_sending.......................................: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
99+
http_req_tls_handshaking...............................: avg=22.4ms min=0s med=0s max=112ms p(90)=67.2ms p(95)=89.59ms
100+
http_reqs..............................................: 5 0.566242/s
101+
iteration_duration.....................................: avg=8.82s min=8.82s med=8.82s max=8.82s p(90)=8.82s p(95)=8.82s
102+
iterations.............................................: 1 0.113248/s
103+
vus....................................................: 1 min=1 max=1
104+
vus_max................................................: 1 min=1 max=1
105+
webvital_cumulative_layout_shift.......................: avg=0 min=0 med=0 max=0 p(90)=0 p(95)=0
106+
webvital_cumulative_layout_shift_good..................: 1 0.113248/s
107+
webvital_first_contentful_paint........................: avg=415.35ms min=302ms med=415.35ms max=528.7ms p(90)=506.03ms p(95)=517.36ms
108+
webvital_first_contentful_paint_good...................: 2 0.226497/s
109+
webvital_first_input_delay.............................: avg=5.59ms min=5.59ms med=5.59ms max=5.59ms p(90)=5.59ms p(95)=5.59ms
110+
webvital_first_input_delay_good........................: 1 0.113248/s
111+
webvital_interaction_to_next_paint.....................: avg=248ms min=248ms med=248ms max=248ms p(90)=248ms p(95)=248ms
112+
webvital_interaction_to_next_paint_needs_improvement...: 1 0.113248/s
113+
webvital_largest_content_paint.........................: avg=528.7ms min=528.7ms med=528.7ms max=528.7ms p(90)=528.7ms p(95)=528.7ms
114+
webvital_largest_content_paint_good....................: 1 0.113248/s
115+
webvital_time_to_first_byte............................: avg=320.59ms min=247.09ms med=320.59ms max=394.1ms p(90)=379.4ms p(95)=386.75ms
116+
webvital_time_to_first_byte_good.......................: 2 0.226497/s
106117
```
107118
108119
</CodeGroup>

src/data/markdown/translated-guides/en/03 Using k6 browser/03 Metrics.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@ title: 'Browser metrics'
33
excerpt: 'An overview of the different browser performance metrics that the browser module tracks.'
44
---
55

6-
<Blockquote mod="attention">
6+
Follow along to learn about:
77

8-
These metrics are still subject to change in the future.
8+
1. The existing browser metrics that k6 browser tracks
9+
2. The Web Vitals and why they are important
10+
3. How to set thresholds for your browser metrics
11+
4. How to separate the browser metrics for different pages
12+
13+
## Existing browser metrics
14+
15+
<Blockquote mod="note" title="">
16+
17+
As of k6 version 0.44.0, k6 browser now natively supports [Web Vitals](https://web.dev/vitals/). In future releases, we will remove the following browser metrics to focus on the standard web vital metrics.
918

1019
</Blockquote>
1120

@@ -16,5 +25,12 @@ Apart from the usual HTTP specific metrics that k6 already tracks, the browser m
1625
| browser_dom_content_loaded | Emitted when the page is loaded but scripts have just started to be executed. |
1726
| browser_first_paint | Emitted when the browser renders the first pixel on the page. |
1827
| browser_first_contentful_paint | Emitted when the browser renders the first DOM element on the page, whether that's a text, image or header. |
19-
| browser_first_meaningful_paint | Emitted when the browser renders the main content from above-the-fold that the users are looking for. |
20-
| browser_loaded | Emitted when the page is fully loaded. |
28+
| browser_loaded | Emitted when the page is fully loaded. |
29+
30+
## Web vitals
31+
32+
### Why are they important?
33+
34+
## Set thresholds for your browser metrics
35+
36+
## Separate browser metrics for different pages

0 commit comments

Comments
 (0)