clear method
WebDriver clear
spec always performs a focus event and a blur event,
which contradict with Pageloader clear
API.
Instead of using the clear
API, we send a CTRL-A, then Backspace key and
an empty string.
Implementation
@override
Future<Null> clear({bool focusBefore = true, bool blurAfter = true}) async =>
_retryWhenStale(() async {
if (focusBefore) await focus();
_single.driver.keyboard.sendChord([sync_wd.Keyboard.control, 'a']);
_single.driver.keyboard.sendChord([sync_wd.Keyboard.backSpace]);
// Some elements do not support `back space`, and some elements'
// [innerText] is detached from themselves, so we send an empty string
// in case the above method does not work.
_single.driver.keyboard.sendChord([sync_wd.Keyboard.control, 'a']);
_single.sendKeys('');
if (blurAfter) await blur();
});