[js] For protect against the remote end sometimes not returning a list for
findElements.
@@ -1045,8 +1045,10 @@ class WebDriver {
let cmd = new command.Command(command.Name.FIND_ELEMENTS).
setParameter('using', locator.using).
setParameter('value', locator.value);
- let res = this.schedule(cmd, 'WebDriver.findElements(' + locator + ')');
- return res.catch(function(e) {
+ return this.schedule(cmd, 'WebDriver.findElements(' + locator + ')')
+ .then(
+ (res) => Array.isArray(res) ? res : [],
+ (e) => {
if (e instanceof error.NoSuchElementError) {
return [];
}
@@ -2076,7 +2078,8 @@ class WebElement {
command.Name.FIND_CHILD_ELEMENTS).
setParameter('using', locator.using).
setParameter('value', locator.value);
- return this.schedule_(cmd, 'WebElement.findElements(' + locator + ')');
+ return this.schedule_(cmd, 'WebElement.findElements(' + locator + ')')
+ .then(result => Array.isArray(result) ? result : []);
}
}
