Skip to content

Commit dc877cc

Browse files
committed
Add docs for locator.clear
1 parent 6b819bc commit dc877cc

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

docs/sources/next/javascript-api/k6-experimental/browser/locator/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Locator can be created with the [page.locator(selector[, options])](https://graf
1919
| Method | Description |
2020
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
2121
| [locator.check([options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator/check) <BWIPT id="471"/> | Select the input checkbox. |
22+
| [locator.clear([options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator/clear) | Clears text boxes and input fields of any existing values. |
2223
| [locator.click([options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator/click) <BWIPT id="471"/> | Mouse click on the chosen element. |
2324
| [locator.dblclick([options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator/dblclick) <BWIPT id="471"/> | Mouse double click on the chosen element. |
2425
| [locator.dispatchEvent(type, eventInit, [options])](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator/dispatchevent) | Dispatches HTML DOM event types e.g. `'click'`. |
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: 'clear([options])'
3+
excerpt: 'Browser module: locator.clear method'
4+
---
5+
6+
# clear([options])
7+
8+
Clears text boxes and input fields (`input`, `textarea` or `contenteditable` elements) of any existing values.
9+
10+
<TableWithNestedRows>
11+
12+
| Parameter | Type | Default | Description |
13+
| ------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| options | object | `null` | |
15+
| options.force | boolean | `false` | Setting this to `true` will bypass the actionability checks (`visible`, `stable`, `enabled`). |
16+
| options.noWaitAfter | boolean | `false` | If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete. |
17+
| 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/). |
18+
19+
</TableWithNestedRows>
20+
21+
### Example
22+
23+
{{< code >}}
24+
25+
```javascript
26+
import { browser } from 'k6/experimental/browser';
27+
28+
export const options = {
29+
scenarios: {
30+
browser: {
31+
executor: 'shared-iterations',
32+
options: {
33+
browser: {
34+
type: 'chromium',
35+
},
36+
},
37+
},
38+
},
39+
};
40+
41+
export default async function () {
42+
const page = browser.newPage();
43+
44+
await page.goto('https://test.k6.io/browser.php');
45+
46+
page.locator('#text1').clear();
47+
48+
page.close();
49+
}
50+
```
51+
52+
{{< /code >}}

0 commit comments

Comments
 (0)