Skip to content

Commit 51a5f18

Browse files
committed
docs: more API documentation
1 parent 9c334bd commit 51a5f18

18 files changed

+594
-18
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,28 @@ Page provides methods to interact with a single tab in a running web browser ins
3232
| [page.isClosed()](/javascript-api/k6-experimental/browser/page/isclosed/) | Checks if the page has been closed. |
3333
| [page.isDisabled(selector, [options])](/javascript-api/k6-experimental/browser/page/isdisabled/) | Checks if the element is `disabled`. |
3434
| [page.isEditable(selector, [options])](/javascript-api/k6-experimental/browser/page/iseditable/) | Checks if the element is `editable`. |
35+
| [page.isEnabled(selector, [options])](/javascript-api/k6-experimental/browser/page/isenabbled/) | Checks if the element is `enabled`. |
36+
| [page.isHidden(selector, [options])](/javascript-api/k6-experimental/browser/page/ishidden/) | Checks if the element is `hidden`. |
37+
| [page.isVisible(selector, [options])](/javascript-api/k6-experimental/browser/page/isvisible/) | Checks if the element is `visible`. |
38+
| [page.keyboard()](/javascript-api/k6-experimental/browser/page/keyboard/) | Returns the [Keyboard](javascript-api/k6-experimental/browser/keyboard/) instance to interact with a virtual keyboard on the page. |
39+
| [page.locator(selector)](/javascript-api/k6-experimental/browser/page/locator/) | Returns an element [Locator](/javascript-api/k6-experimental/browser/locator/). |
40+
| [page.mainFrame()](/javascript-api/k6-experimental/browser/page/mainframe/) | Returns the page's main frame. |
41+
| [page.mouse()](/javascript-api/k6-experimental/browser/page/mouse/) | Returns the [Mouse](javascript-api/k6-experimental/browser/mouse/) instance to interact with a virtual mouse on the page. |
42+
| [page.opener()](/javascript-api/k6-experimental/browser/page/opener/) | Returns the page that opened the current page. |
43+
| [page.press(selector, key, [options])](/javascript-api/k6-experimental/browser/page/press/) | Focuses the element, and then uses `keyboard.down(key)` and `keyboard.up(key)`. |
44+
| [page.opener([options])](/javascript-api/k6-experimental/browser/page/reload/) | Reloads the current page. |
45+
| [page.screenshot([options])](/javascript-api/k6-experimental/browser/page/screenshot/) | Returns the buffer with the captured screenshot from the browser. |
46+
| [page.selectOption(selector, values, [options])](/javascript-api/k6-experimental/browser/page/selectoption/) | Selects one or more options which match the values from a `<select>` element. |
47+
| [page.setContent(html, [options])](/javascript-api/k6-experimental/browser/page/setcontent/) | Sets the supplied html string to the current page. |
48+
| [page.setDefaultNavigationTimeout(timeout)](/javascript-api/k6-experimental/browser/page/setdefaultnavigationtimeout/) | Changes the navigation timeout for [page.goto(url, [options])](/javascript-api/k6-experimental/browser/page/goto/), [page.reload([options])](/javascript-api/k6-experimental/browser/page/reload/), [page.setContent(html, [options])](/javascript-api/k6-experimental/browser/page/setcontent/), and [page.waitForNavigation([options])](/javascript-api/k6-experimental/browser/page/waitfornavigation/) |
49+
| [page.setDefaultTimeout(timeout)](/javascript-api/k6-experimental/browser/page/setdefaulttimeout/) | Changes the timeout for all the methods accepting a `timeout` option. |
3550

3651

3752

3853

3954

4055

4156
<!--
42-
| <a href="https://playwright.dev/docs/api/class-page#page-is-enabled" target="_blank" >page.isEnabled(selector[, options])</a> | - | - |
43-
| <a href="https://playwright.dev/docs/api/class-page#page-is-hidden" target="_blank" >page.isHidden(selector[, options])</a> | - | - |
44-
| <a href="https://playwright.dev/docs/api/class-page#page-is-visible" target="_blank" >page.isVisible(selector[, options])</a> | - | - |
45-
| [page.locator(selector\[, options\])](/javascript-api/k6-experimental/browser/locator/) | - | Creates and returns a new page `locator` given a selector with strict mode on. The strict mode only allows selecting a single matching element, and will throw an error if multiple matches are found. |
46-
| <a href="https://playwright.dev/docs/api/class-page#page-main-frame" target="_blank" >page.mainFrame()</a> | - | - |
47-
| <a href="https://playwright.dev/docs/api/class-page#page-opener" target="_blank" >page.opener()</a> | - | - |
48-
| <a href="https://playwright.dev/docs/api/class-page#page-press" target="_blank" >page.press(selector, key[, options])</a> | - | - |
49-
| <a href="https://playwright.dev/docs/api/class-page#page-reload" target="_blank" >page.reload([options])</a> | - | - |
50-
| <a href="https://playwright.dev/docs/api/class-page#page-screenshot" target="_blank" >page.screenshot([options])</a> | - | - |
51-
| <a href="https://playwright.dev/docs/api/class-page#page-select-option" target="_blank" >page.selectOption(selector, values[, options])</a> | - | - |
52-
| <a href="https://playwright.dev/docs/api/class-page#page-set-checked" target="_blank" >page.setChecked(selector, checked[, options])</a> | - | - |
53-
| <a href="https://playwright.dev/docs/api/class-page#page-set-content" target="_blank" >page.setContent(html[, options])</a> | - | - |
54-
| <a href="https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout" target="_blank" >page.setDefaultNavigationTimeout(timeout)</a> | - | - |
55-
| <a href="https://playwright.dev/docs/api/class-page#page-set-default-timeout" target="_blank" >page.setDefaultTimeout(timeout)</a> | - | - |
5657
| <a href="https://playwright.dev/docs/api/class-page#page-set-extra-http-headers" target="_blank" >page.setExtraHTTPHeaders(headers)</a> | - | - |
5758
| <a href="https://playwright.dev/docs/api/class-page#page-set-input-files" target="_blank" >page.setInputFiles(selector, files[, options])</a> | - | - |
5859
| <a href="https://playwright.dev/docs/api/class-page#page-set-viewport-size" target="_blank" >page.setViewportSize(viewportSize)</a> | - | - |
@@ -71,6 +72,4 @@ Page provides methods to interact with a single tab in a running web browser ins
7172
| <a href="https://playwright.dev/docs/api/class-page#page-wait-for-response" target="_blank" >page.waitForResponse(urlOrPredicate[, options])</a> | - | - |
7273
| <a href="https://playwright.dev/docs/api/class-page#page-wait-for-selector" target="_blank" >page.waitForSelector(selector[, options])</a> | - | - |
7374
| <a href="https://playwright.dev/docs/api/class-page#page-wait-for-timeout" target="_blank" >page.waitForTimeout(timeout)</a> | - | - |
74-
| <a href="https://playwright.dev/docs/api/class-page#page-keyboard" target="_blank" >keyboard</a> | - | - |
75-
| <a href="https://playwright.dev/docs/api/class-page#page-mouse" target="_blank" >mouse</a> | - | - |
7675
| <a href="https://playwright.dev/docs/api/class-page#page-touchscreen" target="_blank" >touchscreen</a> | - | - | -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function () {
1717
const page = browser.newPage();
1818

1919
await page.goto('https://test.k6.io/browser.php');
20-
console.log(page.frames()); // prints [{}]
20+
console.log(page.frames());
2121
}
2222
```
2323

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Navigating to `about:blank` or navigation to the same URL with a different hash,
1414
| url | string | `''` | URL to navigate page to. The url should include scheme, e.g. `https://`. |
1515
| options | object | `null` | |
1616
| options.referer | string| `''` | Referer header value. |
17-
| options.timeout | number | `30000` | Maximum operation time in milliseconds. Pass `0` to disable the timeout. The default value can be changed via the [browserContext.setDefaultNavigationTimeout(timeout)](javascript-api/k6-experimental/browser/browsercontext/setdefaultnavigationtimeout/), [browserContext.setDefaultTimeout(timeout)](javascript-api/k6-experimental/browser/browsercontext/setdefaulttimeout/), `page.setDefaultNavigationTimeout(timeout)` or `page.setDefaultTimeout(timeout)` methods. Setting the value to `0` will disable the timeout. |
17+
| options.timeout | number | `30000` | Maximum operation time in milliseconds. Pass `0` to disable the timeout. The default value can be changed via the [browserContext.setDefaultNavigationTimeout(timeout)](/javascript-api/k6-experimental/browser/browsercontext/setdefaultnavigationtimeout/), [browserContext.setDefaultTimeout(timeout)](/javascript-api/k6-experimental/browser/browsercontext/setdefaulttimeout/), [page.setDefaultNavigationTimeout(timeout)](/javascript-api/k6-experimental/browser/page/setdefaultnavigationtimeout/) or [page.setDefaultTimeout(timeout)](/javascript-api/k6-experimental/browser/page/setdefaulttimeout/) methods. Setting the value to `0` will disable the timeout. |
1818
| options.waitUntil | string | `load` | When to consider operation to have succeeded. See [Events](#events) for more details. |
1919

2020
</TableWithNestedRows>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: 'isEnabled(selector, [options])'
3+
excerpt: 'Browser module: page.isEnabled(selector, [options]) method'
4+
---
5+
6+
<Blockquote mod="note" title="">
7+
8+
Use locator-based [`locator.isEnabled([options])`](/javascript-api/k6-experimental/browser/locator/isenabled/) instead.
9+
10+
</Blockquote>
11+
12+
Checks if the element is `enabled`.
13+
14+
<TableWithNestedRows>
15+
16+
| Parameter | Type | Default | Description |
17+
|-----------------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
18+
| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. |
19+
| options | object | `null` | |
20+
| options.strict | boolean| `false` | When `true`, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. |
21+
| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) or [Page](/javascript-api/k6-experimental/browser/page/). |
22+
23+
</TableWithNestedRows>
24+
25+
### Returns
26+
27+
| Type | Description |
28+
|------|---------------------------------------------------|
29+
| bool | `true` if the element is `enabled`, else `false`. |
30+
31+
### Example
32+
33+
<CodeGroup labels={[]}>
34+
35+
```javascript
36+
import { chromium } from 'k6/experimental/browser';
37+
38+
export default async function () {
39+
const browser = chromium.launch();
40+
const page = browser.newPage();
41+
42+
await page.goto('https://test.k6.io/browser.php');
43+
if (page.isEnabled('#text1')) {
44+
console.log("element is enabled");
45+
}
46+
}
47+
```
48+
49+
</CodeGroup>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: 'isHidden(selector, [options])'
3+
excerpt: 'Browser module: page.isHidden(selector, [options) method'
4+
---
5+
6+
<Blockquote mod="note" title="">
7+
8+
Use locator-based [`locator.isHidden([options])`](/javascript-api/k6-experimental/browser/locator/ishidden/) instead.
9+
10+
</Blockquote>
11+
12+
Checks if the element is `hidden`.
13+
14+
<TableWithNestedRows>
15+
16+
| Parameter | Type | Default | Description |
17+
|-----------------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
18+
| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. |
19+
| options | object | `null` | |
20+
| options.strict | boolean| `false` | When `true`, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. |
21+
| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) or [Page](/javascript-api/k6-experimental/browser/page/). |
22+
23+
</TableWithNestedRows>
24+
25+
### Returns
26+
27+
| Type | Description |
28+
|------|---------------------------------------------------|
29+
| bool | `true` if the element is `hidden`, else `false`. |
30+
31+
### Example
32+
33+
<CodeGroup labels={[]}>
34+
35+
```javascript
36+
import { chromium } from 'k6/experimental/browser';
37+
38+
export default async function () {
39+
const browser = chromium.launch();
40+
const page = browser.newPage();
41+
42+
await page.goto('https://test.k6.io/browser.php');
43+
if (page.isHidden('#input-text-hidden')) {
44+
console.log("element is hidden");
45+
}
46+
}
47+
```
48+
49+
</CodeGroup>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: 'isVisible(selector, [options])'
3+
excerpt: 'Browser module: page.isVisible(selector, [options]) method'
4+
---
5+
6+
<Blockquote mod="note" title="">
7+
8+
Use locator-based [`locator.isVisible([options])`](/javascript-api/k6-experimental/browser/locator/isvisible/) instead.
9+
10+
</Blockquote>
11+
12+
Checks if the element is `visible`.
13+
14+
<TableWithNestedRows>
15+
16+
| Parameter | Type | Default | Description |
17+
|-----------------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
18+
| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. |
19+
| options | object | `null` | |
20+
| options.strict | boolean| `false` | When `true`, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. |
21+
| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](/javascript-api/k6-experimental/browser/browsercontext/) or [Page](/javascript-api/k6-experimental/browser/page/). |
22+
23+
</TableWithNestedRows>
24+
25+
### Returns
26+
27+
| Type | Description |
28+
|------|---------------------------------------------------|
29+
| bool | `true` if the element is `visible`, else `false`. |
30+
31+
### Example
32+
33+
<CodeGroup labels={[]}>
34+
35+
```javascript
36+
import { chromium } from 'k6/experimental/browser';
37+
38+
export default async function () {
39+
const browser = chromium.launch();
40+
const page = browser.newPage();
41+
42+
await page.goto('https://test.k6.io/browser.php');
43+
if (page.isVisible('#text1')) {
44+
console.log("element is visible");
45+
}
46+
}
47+
```
48+
49+
</CodeGroup>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: 'keyboard()'
3+
excerpt: 'Browser module: page.keyboard method'
4+
---
5+
6+
Returns the [Keyboard](javascript-api/k6-experimental/browser/keyboard/) instance to interact with a virtual keyboard on the page.
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 page = browser.newPage();
18+
19+
await page.goto('https://test.k6.io/browser.php');
20+
page.keyboard.press('Tab');
21+
}
22+
```
23+
24+
</CodeGroup>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: 'locator(selector)'
3+
excerpt: 'Browser module: page.locator(selector) method'
4+
---
5+
6+
The method returns an element [Locator](/javascript-api/k6-experimental/browser/locator/). Locators resolve to the element when the action takes place, which means locators can span over navigations where the underlying dom changes.
7+
8+
9+
| Parameter | Type | Default | Description |
10+
|-----------------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
11+
| selector | string | `''` | A selector to use when resolving DOM element. |
12+
13+
14+
### Example
15+
16+
<CodeGroup labels={[]}>
17+
18+
```javascript
19+
import { chromium } from 'k6/experimental/browser';
20+
21+
export default async function () {
22+
const browser = chromium.launch();
23+
const page = browser.newPage();
24+
25+
await page.goto('https://test.k6.io/browser.php');
26+
const textbox = page.locator("#text1");
27+
textbox.focus();
28+
}
29+
```
30+
31+
</CodeGroup>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: 'mainFrame()'
3+
excerpt: 'Browser module: page.mainFrame method'
4+
---
5+
6+
The page's main frame. Page is made up of frames in a hierarchical. At the top is `mainFrame`. A page is guaranteed to have a mainFrame.
7+
8+
### Returns
9+
10+
| Type | Description |
11+
|--------|----------------------------------|
12+
| [Frame](/javascript-api/k6-experimental/browser/frame/) | The page's main frame. |
13+
14+
### Example
15+
16+
<CodeGroup labels={[]}>
17+
18+
```javascript
19+
import { chromium } from 'k6/experimental/browser';
20+
21+
export default async function () {
22+
const browser = chromium.launch();
23+
const page = browser.newPage();
24+
25+
await page.goto('https://test.k6.io/browser.php');
26+
console.log(page.mainFrame());
27+
}
28+
```
29+
30+
</CodeGroup>

0 commit comments

Comments
 (0)