fix(Page.select): assert all values are of type "string". (#1280)

This patch starts asserting that all values are of type "string".

The alternative approach to cast values to strings
might yield a hard-to-debug errors.

Fixes #1276.
This commit is contained in:
Andrey Lushnikov
2017-11-03 19:20:12 -07:00
committed by GitHub
parent 03fefb53f8
commit 5e154dc835
2 changed files with 12 additions and 10 deletions

View File

@@ -418,6 +418,8 @@ class Frame {
* @return {!Promise<!Array<string>>}
*/
async select(selector, ...values){
for (const value of values)
console.assert(helper.isString(value), 'Values must be strings. Found value "' + value + '" of type "' + (typeof value) + '"');
return await this.$eval(selector, (element, values) => {
if (element.nodeName.toLowerCase() !== 'select')
throw new Error('Element is not a <select> element.');