Skip to content

Commit

Permalink
Add browser touchscreen tap
Browse files Browse the repository at this point in the history
Moves the example from page to the touchscreen.tap to prevent redundancy
and improve maintainability of the docs
  • Loading branch information
inancgumus committed May 6, 2024
1 parent b03eb4d commit 931e541
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,3 @@ Returns the [Touchscreen](https://grafana.com/docs/k6/<K6_VERSION>/javascript-ap
| Type | Description |
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| [Touchscreen](https://grafana.com/docs/k6/<K6_VERSION>/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 >}}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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/<K6_VERSION>/javascript-api/k6-experimental/browser/page/touchscreen/) method.

| Method | Description |
| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| [Touchscreen.tap()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/touchscreen/tap) <BWIPT id="436"/> | Simulates a tap. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
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.

<TableWithNestedRows>

| Parameter | Type | Default | Description |
| --------- | ------ | ------- | ----------------- |
| x | number | `0` | The x coordinate. |
| y | number | `0` | The y coordinate. |

</TableWithNestedRows>

### 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 >}}

0 comments on commit 931e541

Please sign in to comment.