diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/_index.md b/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/_index.md index c3fdaff0bd..78bd1963b3 100644 --- a/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/_index.md +++ b/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/_index.md @@ -42,7 +42,7 @@ weight: 04 | elementHandle.selectText([options]) | - | | elementHandle.setChecked(checked[, options]) | - | | [elementHandle.setInputFiles(file[, options])](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/elementhandle/setinputfiles) | Sets the file input element's value to the specified files. | -| elementHandle.tap([options]) | - | +| [elementHandle.tap(options)](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/elementhandle/tap) | Taps the element. | | elementHandle.textContent() | - | | elementHandle.type(text[, options]) | - | | elementHandle.uncheck([options]) | - | diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/tap.md b/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/tap.md new file mode 100644 index 0000000000..56d61fefdd --- /dev/null +++ b/docs/sources/next/javascript-api/k6-experimental/browser/elementhandle/tap.md @@ -0,0 +1,64 @@ +--- +title: 'tap(options)' +description: 'Browser module: elementhandle.tap(options) method' +--- + +# tap(options) + +Taps the element. + + + +| Parameter | Type | Default | Description | +| ------------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| options | object | `null` | | +| options.force | boolean | `false` | Setting this to `true` will bypass the actionability checks (`visible`, `stable`, `enabled`). | +| options.modifiers | string[] | `null` | `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the action. If not specified, currently pressed modifiers are used. | +| options.noWaitAfter | boolean | `false` | If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete. | +| options.position | object | `null` | A point to use relative to the top left corner of the element. If not supplied, a visible point of the element is used. | +| options.position.x | number | `0` | The x coordinate. | +| options.position.y | number | `0` | The y coordinate. | +| 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. | +| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/browsercontext/) or [Page](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/). | +| options.trial | boolean | `false` | Setting this to `true` will perform the actionability checks without performing the action. | + + + +### Returns + +| Type | Description | +| --------------- | -------------------------------------------------------- | +| `Promise` | A Promise that fulfills when the tap action is finished. | + +### Example + +{{< code >}} + +```javascript +import { browser } from 'k6/experimental/browser'; + +export const options = { + scenarios: { + browser: { + executor: 'shared-iterations', + options: { + browser: { + type: 'chromium', + }, + }, + }, + }, +}; + +export default async function () { + const page = browser.newPage({ + hasTouch: true, + }); + + await page.goto('https://test.k6.io/browser.php'); + const el = page.$("#numbers-options"); + await el.tap(); +} +``` + +{{< /code >}} diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/frame/_index.md b/docs/sources/next/javascript-api/k6-experimental/browser/frame/_index.md index 9e30adc955..3176582942 100644 --- a/docs/sources/next/javascript-api/k6-experimental/browser/frame/_index.md +++ b/docs/sources/next/javascript-api/k6-experimental/browser/frame/_index.md @@ -10,7 +10,7 @@ weight: 05 ## Supported APIs -| Method | Playwright Relevant Distinctions | +| Method | Description / Playwright Relevant Distinctions | | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | frame.$(selector[, options]) | - | | frame.check(selector[, options]) | - | @@ -47,7 +47,7 @@ weight: 05 | frame.setChecked(selector, checked[, options]) | - | | frame.setContent(html[, options]) | - | | [frame.setInputFiles(selector, file[, options])](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/frame/setinputfiles) | Sets the file input element's value to the specified files. | -| frame.tap(selector[, options]) | - | +| [frame.tap(selector[, options])](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/frame/tap/) | Taps the first element that matches the `selector`. | | frame.textContent(selector[, options]) | - | | frame.title() | - | | frame.title() | - | diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/frame/tap.md b/docs/sources/next/javascript-api/k6-experimental/browser/frame/tap.md new file mode 100644 index 0000000000..5531918fab --- /dev/null +++ b/docs/sources/next/javascript-api/k6-experimental/browser/frame/tap.md @@ -0,0 +1,65 @@ +--- +title: 'tap(selector[, options])' +description: 'Browser module: frame.tap(selector[, options]) method' +--- + +# tap(selector[, options]) + +Tap the first element that matches the selector. + + + +| Parameter | Type | Default | Description | +| ------------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. | +| options | object | `null` | | +| options.force | boolean | `false` | Setting this to `true` will bypass the actionability checks (`visible`, `stable`, `enabled`). | +| options.modifiers | string[] | `null` | `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the action. If not specified, currently pressed modifiers are used. | +| options.noWaitAfter | boolean | `false` | If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete. | +| options.position | object | `null` | A point to use relative to the top left corner of the element. If not supplied, a visible point of the element is used. | +| options.position.x | number | `0` | The x coordinate. | +| options.position.y | number | `0` | The y coordinate. | +| 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. | +| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/browsercontext/) or [Page](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/). | +| options.trial | boolean | `false` | Setting this to `true` will perform the actionability checks without performing the action. | + + + +### Returns + +| Type | Description | +| --------------- | -------------------------------------------------------- | +| `Promise` | A Promise that fulfills when the tap action is finished. | + +### Example + +{{< code >}} + +```javascript +import { browser } from 'k6/experimental/browser'; + +export const options = { + scenarios: { + browser: { + executor: 'shared-iterations', + options: { + browser: { + type: 'chromium', + }, + }, + }, + }, +}; + +export default async function () { + const page = browser.newPage({ + hasTouch: true, + }); + + await page.goto('https://test.k6.io/browser.php'); + const frame = page.mainFrame(); + await frame.tap("#numbers-options"); +} +``` + +{{< /code >}} diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/page/_index.md b/docs/sources/next/javascript-api/k6-experimental/browser/page/_index.md index b9bf00a456..020df1b079 100644 --- a/docs/sources/next/javascript-api/k6-experimental/browser/page/_index.md +++ b/docs/sources/next/javascript-api/k6-experimental/browser/page/_index.md @@ -62,7 +62,7 @@ Page provides methods to interact with a single tab in a running web browser. A | [page.throttleNetwork(networkProfile)](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/throttlenetwork) | Throttles the network in Chrome/Chromium to slow it down by the specified fields in the `networkProfile` object. | | [page.title()](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/title) | Returns the `page`'s title. | | [page.type(selector, text[, options])](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/type/) | Types the `text` in the first element found that matches the `selector`. | -| [page.touchScreen](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/touchscreen) | Returns the [Touchscreen](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/touchscreen) instance to interact with a virtual touchscreen on the page. | +| [page.touchscreen](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/touchscreen) | Returns the [Touchscreen](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/touchscreen) instance to interact with a virtual touchscreen on the page. | | [page.uncheck(selector[, options])](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/uncheck/) | Unselects an input `checkbox` element. | | [page.url()](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/url) | Returns the `page`'s URL. | | [page.viewportSize()](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/viewportsize) | Returns the `page`'s size (width and height). | diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/page/touchscreen.md b/docs/sources/next/javascript-api/k6-experimental/browser/page/touchscreen.md index f241f4d9bf..f6240a1f64 100644 --- a/docs/sources/next/javascript-api/k6-experimental/browser/page/touchscreen.md +++ b/docs/sources/next/javascript-api/k6-experimental/browser/page/touchscreen.md @@ -1,9 +1,9 @@ --- -title: 'touchScreen' -description: 'Browser module: page.touchScreen method' +title: 'touchscreen' +description: 'Browser module: page.touchscreen method' --- -# touchScreen +# touchscreen Returns the [Touchscreen](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/touchscreen/) instance to interact with a virtual touchscreen on the page. @@ -12,33 +12,3 @@ Returns the [Touchscreen](https://grafana.com/docs/k6//javascript-ap | Type | Description | | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | [Touchscreen](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/touchscreen/) | The `Touchscreen` instance associated with the page. | - -### Example - -{{< code >}} - -```javascript -import { browser } from 'k6/experimental/browser'; - -export const options = { - scenarios: { - browser: { - executor: 'shared-iterations', - options: { - browser: { - type: 'chromium', - }, - }, - }, - }, -}; - -export default async function () { - const page = browser.newPage(); - - await page.goto('https://test.k6.io/browser.php'); - page.touchScreen.tap(50, 50); -} -``` - -{{< /code >}} diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen.md b/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen.md deleted file mode 100644 index f019efac6f..0000000000 --- a/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: 'Touchscreen' -description: 'Browser module: Touchscreen Class' -weight: 13 ---- - -# Touchscreen - -{{< docs/shared source="k6" lookup="browser-module-wip.md" version="" >}} - -## Supported APIs - -| Method | Playwright Relevant Distinctions | -| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -| touchscreen.tap(x, y) | - | diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen/_index.md b/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen/_index.md new file mode 100644 index 0000000000..a90f9228c4 --- /dev/null +++ b/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen/_index.md @@ -0,0 +1,13 @@ +--- +title: 'Touchscreen' +description: 'Browser module: Touchscreen Class' +weight: 13 +--- + +# Touchscreen + +The `Touchscreen` class allows to interact with a virtual touchscreen. A `Touchscreen` instance can be obtained by calling the [`page.touchscreen`](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/touchscreen/) method. + +| Method | Description | +| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | +| [Touchscreen.tap()](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/touchscreen/tap) | Simulates a tap. | diff --git a/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen/tap.md b/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen/tap.md new file mode 100644 index 0000000000..6b052e2c92 --- /dev/null +++ b/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen/tap.md @@ -0,0 +1,49 @@ +--- +title: 'tap()' +description: 'Browser module: Touchscreen.tap method' +--- + +# tap() + +Simulates a tap (dispatches a `touchstart` and `touchend` events) at the specified coordinates. The `x` and `y` arguments are the coordinates of the tap relative to the top-left corner of the main frame. + + + +| Parameter | Type | Default | Description | +| --------- | ------ | ------- | ----------------- | +| x | number | `0` | The x coordinate. | +| y | number | `0` | The y coordinate. | + + + +### Example + +{{< code >}} + +```javascript +import { browser } from 'k6/experimental/browser'; + +export const options = { + scenarios: { + browser: { + executor: 'shared-iterations', + options: { + browser: { + type: 'chromium', + }, + }, + }, + }, +}; + +export default async function () { + const page = browser.newPage({ + hasTouch: true, + }); + + const touchscreen = page.touchscreen; + await touchscreen.tap(50, 50); +} +``` + +{{< /code >}}