Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): properly clean input field #860

Merged
merged 2 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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