diff --git a/javascript/node/selenium-webdriver/chromium.js b/javascript/node/selenium-webdriver/chromium.js index 857f1386f619a..89bf3dce25a09 100644 --- a/javascript/node/selenium-webdriver/chromium.js +++ b/javascript/node/selenium-webdriver/chromium.js @@ -549,6 +549,22 @@ class Options extends Capabilities { return this } + /** + * Sets a list of the window types that will appear when getting window + * handles. For access to elements, include "webview" in the list. + * @param {...(string|!Array)} args The window types that will appear + * when getting window handles. + * @return {!Options} A self reference. + */ + windowTypes(...args) { + let windowTypes = (this.options_.windowTypes || []).concat(...args); + if (windowTypes.length) { + this.options_.windowTypes = windowTypes; + } + return this; + } + + /** * Converts this instance to its JSON wire protocol representation. Note this * function is an implementation not intended for general use. diff --git a/javascript/node/selenium-webdriver/test/chrome/options_test.js b/javascript/node/selenium-webdriver/test/chrome/options_test.js index 352a7e4c0fa87..a20886113751d 100644 --- a/javascript/node/selenium-webdriver/test/chrome/options_test.js +++ b/javascript/node/selenium-webdriver/test/chrome/options_test.js @@ -91,6 +91,24 @@ describe('chrome.Options', function () { ) }) }) + + describe('windowTypes', function() { + it('takes var_args', function() { + let options = new chrome.Options(); + assert.strictEqual(options.options_.windowTypes, undefined); + + options.windowTypes('a', 'b'); + assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b']); + }) + + it('flattens input arrays', function() { + let options = new chrome.Options(); + assert.strictEqual(options.options_.windowTypes, undefined); + + options.windowTypes(['a', 'b'], 'c', [1, 2], 3); + assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b', 'c', 1, 2, 3]); + }) + }) }) test.suite(