From 5e154dc835fcacdec6e680a695630352dae959dc Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Fri, 3 Nov 2017 19:20:12 -0700 Subject: [PATCH] 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. --- lib/FrameManager.js | 2 ++ test/test.js | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/FrameManager.js b/lib/FrameManager.js index 578ac9a7..ab645e7c 100644 --- a/lib/FrameManager.js +++ b/lib/FrameManager.js @@ -418,6 +418,8 @@ class Frame { * @return {!Promise>} */ 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 ', SX(async function() { let error = null; await page.goto(PREFIX + '/input/select.html'); await page.select('body', '').catch(e => error = e); expect(error.message).toContain('Element is not a