fix(test): properly clean input field (#860)

This commit is contained in:
Andrey Lushnikov 2020-02-05 18:11:33 -08:00 committed by GitHub
parent fa6a5edb31
commit a72784a677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -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)

View file

@ -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)[]) {