Skip to content

Commit

Permalink
Add new clear method to locator class in k6
Browse files Browse the repository at this point in the history
This adds the new clear method to the locator class which is part of a
change in the browser module in k6.
  • Loading branch information
ankur22 committed Jan 8, 2024
1 parent 5a99511 commit 6d7f324
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions types/k6/experimental/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,21 @@ export interface Keyboard {
* React, Vue, etc.
*/
export interface Locator {
/**
* Clears text boxes and input fields of any existing values after navigating
* to a page or or values that were entered earlier in the test.
*
* **Usage**
*
* ```js
* // Clears the input field matching the selector.
* page.locator('input[name="login"]').clear();
* ```
*
* @param options Options to use.
*/
clear(options?: ElementHandleOptions): void;

/**
* Mouse click on the chosen element.
* @param options Options to use.
Expand Down
5 changes: 5 additions & 0 deletions types/k6/test/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,11 @@ mouse.up({ clickCount: 2 });
//
const locator = page.locator(selector);

// $ExpectType void
locator.clear();
// $ExpectType void
locator.clear({ noWaitAfter: true, timeout: 10000 });

// $ExpectType Promise<void>
locator.click();
// $ExpectType Promise<void>
Expand Down

0 comments on commit 6d7f324

Please sign in to comment.