Skip to content

Commit c059238

Browse files
inancgumusschalksnyman
authored andcommitted
Async frame.press
1 parent 0f92434 commit c059238

File tree

1 file changed

+43
-0
lines changed
  • docs/sources/next/javascript-api/k6-browser/frame

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: 'press(selector, key[, options])'
3+
description: 'Browser module: frame.press(selector, key[, options]) method'
4+
---
5+
6+
# press(selector, key[, options])
7+
8+
{{% admonition type="warning" %}}
9+
10+
Use locator-based [`locator.press()`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/press/) instead.
11+
12+
{{% /admonition %}}
13+
14+
Focuses the element, and then uses `keyboard.down(key)` and `keyboard.up(key)`.
15+
16+
A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values).
17+
18+
Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
19+
20+
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
21+
22+
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
23+
24+
Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
25+
<TableWithNestedRows>
26+
27+
| Parameter | Type | Default | Description |
28+
| ------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29+
| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. |
30+
| key | string | `''` | Name of the key to press or a character to generate, such as `ArrowLeft` or `a`. A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values). |
31+
| options | object | `null` | |
32+
| options.delay | number | `0` | Milliseconds to wait between `keydown` and `keyup`. |
33+
| options.noWaitAfter | boolean | `false` | If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete. |
34+
| 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. |
35+
| 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-browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/). |
36+
37+
</TableWithNestedRows>
38+
39+
### Returns
40+
41+
| Type | Description |
42+
| --------------- | ---------------------------------------------------------- |
43+
| `Promise<void>` | A Promise that fullfils when the press action is finished. |

0 commit comments

Comments
 (0)