Skip to content

Commit

Permalink
Fix error code for unsupported locator strategy
Browse files Browse the repository at this point in the history
W3C WebDriver spec indicates that when an unsupported locator strategy
is used in Find Element or Find Elements command, the implementation
should return "invalid argument" error. The existing JavaScript atoms
for these commands didn't specify an error code, resulting in the
default "unknown error". This commit fixes the error code.

Signed-off-by: Alexei Barantsev <[email protected]>
  • Loading branch information
JohnChen0 authored and barancev committed Nov 21, 2018
1 parent 4da217c commit b3062fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions javascript/atoms/locators/locators.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ bot.locators.findElement = function(target, opt_root) {
return strategy.single(target[key], root);
}
}
throw Error('Unsupported locator strategy: ' + key);
throw new bot.Error(bot.ErrorCode.INVALID_ARGUMENT,
'Unsupported locator strategy: ' + key);
};


Expand All @@ -154,5 +155,6 @@ bot.locators.findElements = function(target, opt_root) {
return strategy.many(target[key], root);
}
}
throw Error('Unsupported locator strategy: ' + key);
throw new bot.Error(bot.ErrorCode.INVALID_ARGUMENT,
'Unsupported locator strategy: ' + key);
};

0 comments on commit b3062fc

Please sign in to comment.