|
| 1 | +--- |
| 2 | +title: 'type(selector, text[, options])' |
| 3 | +description: 'Browser module: frame.type(selector, text[, options]) method' |
| 4 | +--- |
| 5 | + |
| 6 | +# type(selector, text[, options]) |
| 7 | + |
| 8 | +{{% admonition type="warning" %}} |
| 9 | + |
| 10 | +Use locator-based [`locator.type()`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/type/) instead. |
| 11 | + |
| 12 | +{{% /admonition %}} |
| 13 | + |
| 14 | +Type the `text` in the first element found that matches the selector. |
| 15 | + |
| 16 | +<TableWithNestedRows> |
| 17 | + |
| 18 | +| Parameter | Type | Default | Description | |
| 19 | +| ------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 20 | +| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. | |
| 21 | +| text | string | `''` | A text to type into a focused element. | |
| 22 | +| options | object | `null` | | |
| 23 | +| options.delay | number | `0` | Milliseconds to wait between key presses. Defaults to `0`. | |
| 24 | +| options.noWaitAfter | boolean | `false` | If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete. | |
| 25 | +| 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. | |
| 26 | +| 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/). | |
| 27 | + |
| 28 | +</TableWithNestedRows> |
| 29 | + |
| 30 | +### Returns |
| 31 | + |
| 32 | +| Type | Description | |
| 33 | +| --------------- | ----------------------------------------------------- | |
| 34 | +| `Promise<void>` | A Promise that fulfills when the text has been typed. | |
0 commit comments