Skip to content

Commit

Permalink
fix(test): properly clean input field (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Feb 6, 2020
1 parent fa6a5ed commit a72784a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/api.md
Expand Up @@ -1012,6 +1012,8 @@ const fs = require('fs');
This method focuses the element and triggers an `input` event after filling.
If there's no text `<input>`, `<textarea>` or `[contenteditable]` element matching `selector`, the method throws an error.

> **NOTE** Pass empty string as a value to clear the input field.
Shortcut for [page.mainFrame().fill()](#framefillselector-value)

#### page.focus(selector, options)
Expand Down
5 changes: 4 additions & 1 deletion src/dom.ts
Expand Up @@ -414,7 +414,10 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
}, value);
if (error)
throw new Error(error);
await this._page.keyboard.sendCharacters(value);
if (value)
await this._page.keyboard.sendCharacters(value);
else
await this._page.keyboard.press('Delete');
}

async setInputFiles(...files: (string | types.FilePayload)[]) {
Expand Down

0 comments on commit a72784a

Please sign in to comment.