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

Docs: Browser documentation updates for v1.0.0 #1208

Merged
merged 56 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1195e76
Remove this later
inancgumus Jun 8, 2023
ed89187
Remove k6 browser's browser.on method doc (#1197)
ka3de Jun 9, 2023
490460c
Update browser example
inancgumus Jun 9, 2023
162010b
Update running browser tests
inancgumus Jun 6, 2023
7885bd1
Update browser overview
inancgumus Jun 6, 2023
457ef6c
Update browser metrics
inancgumus Jun 6, 2023
aad2885
Update k6 version to latest
inancgumus Jun 7, 2023
516f00a
Change testk6 to browser
inancgumus Jun 7, 2023
ed5419b
Remove web vitals explanation
inancgumus Jun 7, 2023
aeffe8b
Update k6 version to latest
inancgumus Jun 7, 2023
2abf2bd
Remove browser module version
inancgumus Jun 7, 2023
e73d149
Fix browser example
inancgumus Jun 7, 2023
e4c4b22
Remove BrowserType
inancgumus Jun 7, 2023
342ab2c
Remove BrowserContext.Browser
inancgumus Jun 7, 2023
b7c48d5
Rename Browser class to module
inancgumus Jun 7, 2023
3369ce0
Move Browser to the root page
inancgumus Jun 7, 2023
32e7c0f
Update the browser module example in the root
inancgumus Jun 7, 2023
87986f2
Fix links to browser class
inancgumus Jun 7, 2023
81d81cc
Rename browsertest to browserTest
inancgumus Jun 7, 2023
f8a5396
Rephrase browser related text
inancgumus Jun 8, 2023
09a57b0
Replace newContext with newPage
inancgumus Jun 9, 2023
4695b5f
Remove browser.on
inancgumus Jun 9, 2023
c3dbbd9
Update browser examples
inancgumus Jun 9, 2023
5c2725d
Update running browser tests explanation
inancgumus Jun 9, 2023
e4993fa
Remove browser.close
inancgumus Jun 9, 2023
7bf47eb
Remove auto chromium launch explanation
inancgumus Jun 9, 2023
7ed9fae
Rename to fid web vital
ankur22 May 16, 2023
eb2f30d
Rename to ttfb web vital
ankur22 May 16, 2023
94790f3
Rename cls web vital
ankur22 May 16, 2023
b5a752c
Rename fcp web vital
ankur22 May 16, 2023
1c65670
Disable vale for web vital metrics reference page
ankur22 May 16, 2023
8c23da4
Remove browser.close from the module API
inancgumus Jun 9, 2023
ba054f3
Add browser launch options to the root page
inancgumus Jun 13, 2023
9c50c69
Remove unnecessary check
inancgumus Jun 13, 2023
99cd9e3
Add link to the browser API root
inancgumus Jun 13, 2023
1d3be6d
Fix the browser guide link
inancgumus Jun 13, 2023
732a3fa
Add browser cmd example
inancgumus Jun 13, 2023
5427f8e
Fix typo in browser guide
inancgumus Jun 14, 2023
e5bba26
Add check back to waitforfunc
inancgumus Jun 15, 2023
aa4c614
Add browser module run example
inancgumus Jun 15, 2023
b567e1b
Update devices example to H2
inancgumus Jun 15, 2023
8514dcd
Add headful to vale accepts
inancgumus Jun 16, 2023
158f1a7
Update browser.contexts to browser.context
ankur22 Jun 30, 2023
5fba848
Rename contexts to context
ankur22 Jun 30, 2023
356c2e4
Update newContext to reflect 1-to-1 change
ankur22 Jun 30, 2023
2ba2508
Update newPage to reflect 1-to-1 change
ankur22 Jun 30, 2023
76a32df
Update src/data/markdown/docs/02 javascript api/07 k6-experimental/01…
ankur22 Jul 5, 2023
1d2d85e
Fix example and close declared page instances
ankur22 Jul 7, 2023
913786c
Add browser page close notice (#1270)
inancgumus Aug 1, 2023
f8e97e8
Fix unopened blockquote
inancgumus Aug 4, 2023
cde2145
Add running browser tests with scenarios notice (#1280)
inancgumus Aug 7, 2023
cb5fc9d
Move some browser docs to recommended practices.
inancgumus Aug 9, 2023
2bfcbbb
Redirect selecting elements
inancgumus Aug 10, 2023
6f62153
Redirect page object model
inancgumus Aug 10, 2023
5921afb
update k6 run command to include docker example
mdcruz Aug 10, 2023
a4beb46
Improve importable properties explanation
inancgumus Aug 14, 2023
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
3 changes: 2 additions & 1 deletion .vale/Vocab/docs/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,5 @@ shm
srgb
kwallet
referer
scrollable
scrollable
headful
11 changes: 11 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,17 @@ const createRedirects = ({ actions }) => {
isPermanent: true,
});

createRedirect({
fromPath: '/using-k6-browser/selecting-elements/',
toPath: '/using-k6-browser/recommended-practices/selecting-elements/',
isPermanent: true,
});
createRedirect({
fromPath: '/using-k6-browser/examples/page-object-model/',
toPath: '/using-k6-browser/recommended-practices/page-object-model/',
isPermanent: true,
});

const redirects = {
'/javascript-api/k6-http/cookiejar-k6-http/':
'/javascript-api/k6-http/cookiejar/',
Expand Down

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
****---
title: "Browser module"
excerpt: "Browser module"
---

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:
- [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) which is where you can set a variety of attributes to control the behavior of pages;
- and [Page](/javascript-api/k6-experimental/browser/page/) which is where your rendered site is displayed.

A new browser process is automatically created when you use the `newContext` method of the `browser` module (`'k6/experimental/browser'`).

| Method | Description |
|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| [browser.contexts()](/javascript-api/k6-experimental/browser/browser-module/contexts) | Lets you access all open [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/)s. |
| [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. |
| [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/). |
| [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. |
| [browser.version()](/javascript-api/k6-experimental/browser/browser-module/version/) | Returns the browser application's version. |

### Example

<CodeGroup labels={[]}>

```javascript
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
thresholds: {
checks: ["rate==1.0"]
}
}

export default async function () {
const page = browser.newPage();
try {
await page.goto('https://test.k6.io/');
} finally {
page.close();
}
}
```

</CodeGroup>
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ title: "BrowserContext"
excerpt: "Browser module: BrowserContext Class"
---

`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.
`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.

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

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`.


| Method | Description |
|-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [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. |
| [BrowserContext.addCookies()](/javascript-api/k6-experimental/browser/browsercontext/addcookies/) | Adds cookies into the `BrowserContext`. |
| [BrowserContext.clearCookies()](/javascript-api/k6-experimental/browser/browsercontext/clearcookies/) <BWIPT id="442"/> | Clear the `BrowserContext`'s cookies. |
| [BrowserContext.clearPermissions()](/javascript-api/k6-experimental/browser/browsercontext/clearpermissions) <BWIPT id="443"/> | Clears all permission overrides for the `BrowserContext`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@ Adds cookies into the `BrowserContext`. All pages within this context will have
<CodeGroup labels={[]}>

```javascript
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}

export default async function () {
const browser = chromium.launch();
const context = browser.newContext();

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

const page = context.newPage();
await page.goto('https://test.k6.io/');
page.close();
}
```

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ Clears the `BrowserContext`'s cookies.
<CodeGroup labels={[]}>

```javascript
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}

export default async function () {
const browser = chromium.launch();
const context = browser.newContext();
const page = context.newPage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ Clears all permission overrides for the `BrowserContext`.
<CodeGroup labels={[]}>

```javascript
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}

export default function () {
const browser = chromium.launch();
const context = browser.newContext();
context.grantPermissions(['clipboard-read']);
// do stuff ...
Expand Down
Loading
Loading