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

Improve browser Touchscreen and tap #1581

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ weight: 04
| <a href="https://playwright.dev/docs/api/class-elementhandle#element-handle-select-text" target="_blank" >elementHandle.selectText([options])</a> | - |
| <a href="https://playwright.dev/docs/api/class-elementhandle#element-handle-set-checked" target="_blank" >elementHandle.setChecked(checked[, options])</a> | - |
| [elementHandle.setInputFiles(file[, options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/elementhandle/setinputfiles) | Sets the file input element's value to the specified files. |
| <a href="https://playwright.dev/docs/api/class-elementhandle#element-handle-tap" target="_blank" >elementHandle.tap([options])</a> | - |
| [elementHandle.tap(options)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/elementhandle/tap) | Taps the element. |
| <a href="https://playwright.dev/docs/api/class-elementhandle#element-handle-text-content" target="_blank" >elementHandle.textContent()</a> | - |
| <a href="https://playwright.dev/docs/api/class-elementhandle#element-handle-type" target="_blank" >elementHandle.type(text[, options])</a> | - |
| <a href="https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck" target="_blank" >elementHandle.uncheck([options])</a> | - |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: 'tap(options)'
description: 'Browser module: elementhandle.tap(options) method'
---

# tap(options)

Taps the element.

<TableWithNestedRows>

| 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/<K6_VERSION>/javascript-api/k6-experimental/browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/page/). |
| options.trial | boolean | `false` | Setting this to `true` will perform the actionability checks without performing the action. |

</TableWithNestedRows>

### Returns

| Type | Description |
| --------------- | -------------------------------------------------------- |
| `Promise<void>` | 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 >}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ weight: 05

## Supported APIs

| Method | Playwright Relevant Distinctions |
| Method | Description / Playwright Relevant Distinctions |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| <a href="https://playwright.dev/docs/api/class-frame#frame-query-selector" target="_blank" >frame.$(selector[, options])</a> | - |
| <a href="https://playwright.dev/docs/api/class-frame#frame-check" target="_blank" >frame.check(selector[, options])</a> | - |
Expand Down Expand Up @@ -47,7 +47,7 @@ weight: 05
| <a href="https://playwright.dev/docs/api/class-frame#frame-set-checked" target="_blank" >frame.setChecked(selector, checked[, options])</a> | - |
| <a href="https://playwright.dev/docs/api/class-frame#frame-set-content" target="_blank" >frame.setContent(html[, options])</a> | - |
| [frame.setInputFiles(selector, file[, options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/frame/setinputfiles) | Sets the file input element's value to the specified files. |
| <a href="https://playwright.dev/docs/api/class-frame#frame-tap" target="_blank" >frame.tap(selector[, options])</a> | - |
| [frame.tap(selector[, options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/frame/tap/) <BWIPT id="436"/> | Taps the first element that matches the `selector`. |
| <a href="https://playwright.dev/docs/api/class-frame#frame-text-content" target="_blank" >frame.textContent(selector[, options])</a> | - |
| <a href="https://playwright.dev/docs/api/class-frame#frame-title" target="_blank" >frame.title()</a> | - |
| <a href="https://playwright.dev/docs/api/class-frame#frame-type" target="_blank" >frame.title()</a> | - |
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

<TableWithNestedRows>

| 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/<K6_VERSION>/javascript-api/k6-experimental/browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/page/). |
| options.trial | boolean | `false` | Setting this to `true` will perform the actionability checks without performing the action. |

</TableWithNestedRows>

### Returns

| Type | Description |
| --------------- | -------------------------------------------------------- |
| `Promise<void>` | 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 >}}
Loading
Loading