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..ad8783c120 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 @@ -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 index f019efac6f..97b0e4cc3f 100644 --- a/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen.md +++ b/docs/sources/next/javascript-api/k6-experimental/browser/touchscreen.md @@ -6,10 +6,38 @@ weight: 13 # Touchscreen -{{< docs/shared source="k6" lookup="browser-module-wip.md" version="" >}} +The `Touchscreen` class allows to interact with a virtual touchscreen. It can only be used in +[BrowserContext](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/newcontext)s that have been initialized with the `hasTouch` option set to `true`. A `Touchscreen` instance can be obtained by calling the [`page.touchscreen`](https://grafana.com/docs/k6//javascript-api/k6-experimental/browser/page/touchscreen/) method. -## Supported APIs +| Method | Description | +| ----------------------- | ----------- | +| Touchscreen.tap(x, y) | 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. | -| Method | Playwright Relevant Distinctions | -| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -| touchscreen.tap(x, y) | - | +### 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(); + const touchScreen = page.touchScreen; + await touchscreen.tap(50, 50); +} +``` + +{{< /code >}}