Throw error when unfocus fails after clearing element
@@ -92,7 +92,13 @@ bot.action.clear = function(element) {
element.value = '';
bot.events.fire(element, bot.events.EventType.CHANGE);
bot.events.fire(element, bot.events.EventType.BLUR);
- bot.action.LegacyDevice_.focusOnElement(bot.getDocument().body);
+ var body = bot.getDocument().body;
+ if (body) {
+ bot.action.LegacyDevice_.focusOnElement(body);
+ } else {
+ throw new bot.Error(bot.ErrorCode.UNKNOWN_ERROR,
+ 'Cannot unfocus element after clearing.');
+ }
} else if (bot.dom.isElement(element, goog.dom.TagName.INPUT) &&
(element.getAttribute('type') && element.getAttribute('type').toLowerCase() == "number")) {
// number input fields that have invalid inputs
