Skip to content

Commit fa7a3cc

Browse files
authored
Merge pull request #1208 from grafana/update/browser-cloud-updates
All browser cloud documentation updates for v1.0.0
2 parents bef8be9 + a4beb46 commit fa7a3cc

File tree

121 files changed

+1912
-849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1912
-849
lines changed

.vale/Vocab/docs/accept.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,5 @@ shm
210210
srgb
211211
kwallet
212212
referer
213-
scrollable
213+
scrollable
214+
headful

gatsby-node.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,17 @@ const createRedirects = ({ actions }) => {
16701670
isPermanent: true,
16711671
});
16721672

1673+
createRedirect({
1674+
fromPath: '/using-k6-browser/selecting-elements/',
1675+
toPath: '/using-k6-browser/recommended-practices/selecting-elements/',
1676+
isPermanent: true,
1677+
});
1678+
createRedirect({
1679+
fromPath: '/using-k6-browser/examples/page-object-model/',
1680+
toPath: '/using-k6-browser/recommended-practices/page-object-model/',
1681+
isPermanent: true,
1682+
});
1683+
16731684
const redirects = {
16741685
'/javascript-api/k6-http/cookiejar-k6-http/':
16751686
'/javascript-api/k6-http/cookiejar/',

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

Lines changed: 193 additions & 16 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/01 Browser class/close.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/01 Browser class/contexts.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/01 Browser class/on--event--.md

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
****---
2+
title: "Browser module"
3+
excerpt: "Browser module"
4+
---
5+
6+
The `Browser` module is the entry point for all your tests, and it is what interacts with the actual web browser via [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) (CDP). It manages:
7+
- [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) which is where you can set a variety of attributes to control the behavior of pages;
8+
- and [Page](/javascript-api/k6-experimental/browser/page/) which is where your rendered site is displayed.
9+
10+
A new browser process is automatically created when you use the `newContext` method of the `browser` module (`'k6/experimental/browser'`).
11+
12+
| Method | Description |
13+
|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
14+
| [browser.contexts()](/javascript-api/k6-experimental/browser/browser-module/contexts) | Lets you access all open [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/)s. |
15+
| [browser.isConnected](/javascript-api/k6-experimental/browser/browser-module/isconnected) <BWIPT id="453"/> | Indicates whether the [CDP](https://chromedevtools.github.io/devtools-protocol/) connection to the browser process is active or not. |
16+
| [browser.newContext([options])](/javascript-api/k6-experimental/browser/browser-module/newcontext/) <BWIPT id="455"/> | Creates and returns a new [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/). |
17+
| [browser.newPage([options])](/javascript-api/k6-experimental/browser/browser-module/newpage) <BWIPT id="455"/> | Creates a new [Page](/javascript-api/k6-experimental/browser/page/) in a new [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) and returns the page. |
18+
| [browser.version()](/javascript-api/k6-experimental/browser/browser-module/version/) | Returns the browser application's version. |
19+
20+
### Example
21+
22+
<CodeGroup labels={[]}>
23+
24+
```javascript
25+
import { browser } from 'k6/experimental/browser';
26+
27+
export const options = {
28+
scenarios: {
29+
browser: {
30+
executor: 'shared-iterations',
31+
options: {
32+
browser: {
33+
type: 'chromium',
34+
},
35+
},
36+
},
37+
},
38+
thresholds: {
39+
checks: ["rate==1.0"]
40+
}
41+
}
42+
43+
export default async function () {
44+
const page = browser.newPage();
45+
try {
46+
await page.goto('https://test.k6.io/');
47+
} finally {
48+
page.close();
49+
}
50+
}
51+
```
52+
53+
</CodeGroup>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ title: "BrowserContext"
33
excerpt: "Browser module: BrowserContext Class"
44
---
55

6-
`BrowserContext`s provide a way to operate multiple independent sessions, with separate pages, cache, and cookies. A default `BrowserContext` is created when a [Browser](/javascript-api/k6-experimental/browser/browser-class/) is launched.
6+
`BrowserContext`s provide a way to operate multiple independent sessions, with separate pages, cache, and cookies. A default `BrowserContext` is created when a browser is launched.
77

8-
The [Browser](/javascript-api/k6-experimental/browser/browser-class/) type is used to create a new `BrowserContext`.
8+
The [browser module API](/javascript-api/k6-experimental/browser#browser-module-api) is used to create a new `BrowserContext`.
99

1010
If a [page](/javascript-api/k6-experimental/browser/page/) opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's `BrowserContext`.
1111

1212

1313
| Method | Description |
1414
|-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
15-
| [BrowserContext.browser()](/javascript-api/k6-experimental/browser/browsercontext/browser-instance/) | Returns the [Browser](/javascript-api/k6-experimental/browser/browser-class/) instance that this `BrowserContext` belongs to. |
1615
| [BrowserContext.addCookies()](/javascript-api/k6-experimental/browser/browsercontext/addcookies/) | Adds cookies into the `BrowserContext`. |
1716
| [BrowserContext.clearCookies()](/javascript-api/k6-experimental/browser/browsercontext/clearcookies/) <BWIPT id="442"/> | Clear the `BrowserContext`'s cookies. |
1817
| [BrowserContext.clearPermissions()](/javascript-api/k6-experimental/browser/browsercontext/clearpermissions) <BWIPT id="443"/> | Clears all permission overrides for the `BrowserContext`. |

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,22 @@ Adds cookies into the `BrowserContext`. All pages within this context will have
1010
<CodeGroup labels={[]}>
1111

1212
```javascript
13-
import { chromium } from 'k6/experimental/browser';
13+
import { browser } from 'k6/experimental/browser';
14+
15+
export const options = {
16+
scenarios: {
17+
browser: {
18+
executor: 'shared-iterations',
19+
options: {
20+
browser: {
21+
type: 'chromium',
22+
},
23+
},
24+
},
25+
},
26+
}
1427

1528
export default async function () {
16-
const browser = chromium.launch();
1729
const context = browser.newContext();
1830

1931
context.addCookies([
@@ -26,6 +38,7 @@ export default async function () {
2638

2739
const page = context.newPage();
2840
await page.goto('https://test.k6.io/');
41+
page.close();
2942
}
3043
```
3144

0 commit comments

Comments
 (0)