Skip to content

Commit 18c9454

Browse files
txavaharsha509
andauthored
[js] Add windowTypes option support for ChromiumDriver (#7897)
* [js] windowTypes option support for ChromiumDriver Adds support for setting windowTypes option for ChromeDriver, which allows getting an extra set of window type handles like webview handles. For more info, see: https://chromedriver.chromium.org/capabilities * [js] Add test for windowTypes option support for ChromiumDriver * [js] Replacing deepEqual(deprecated) with deepStrictEqual Co-authored-by: Sri Harsha <[email protected]> Co-authored-by: Sri Harsha <[email protected]>
1 parent 8aafd3f commit 18c9454

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

javascript/node/selenium-webdriver/chromium.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,22 @@ class Options extends Capabilities {
549549
return this
550550
}
551551

552+
/**
553+
* Sets a list of the window types that will appear when getting window
554+
* handles. For access to <webview> elements, include "webview" in the list.
555+
* @param {...(string|!Array<string>)} args The window types that will appear
556+
* when getting window handles.
557+
* @return {!Options} A self reference.
558+
*/
559+
windowTypes(...args) {
560+
let windowTypes = (this.options_.windowTypes || []).concat(...args);
561+
if (windowTypes.length) {
562+
this.options_.windowTypes = windowTypes;
563+
}
564+
return this;
565+
}
566+
567+
552568
/**
553569
* Converts this instance to its JSON wire protocol representation. Note this
554570
* function is an implementation not intended for general use.

javascript/node/selenium-webdriver/test/chrome/options_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@ describe('chrome.Options', function () {
9191
)
9292
})
9393
})
94+
95+
describe('windowTypes', function() {
96+
it('takes var_args', function() {
97+
let options = new chrome.Options();
98+
assert.strictEqual(options.options_.windowTypes, undefined);
99+
100+
options.windowTypes('a', 'b');
101+
assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b']);
102+
})
103+
104+
it('flattens input arrays', function() {
105+
let options = new chrome.Options();
106+
assert.strictEqual(options.options_.windowTypes, undefined);
107+
108+
options.windowTypes(['a', 'b'], 'c', [1, 2], 3);
109+
assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b', 'c', 1, 2, 3]);
110+
})
111+
})
94112
})
95113

96114
test.suite(

0 commit comments

Comments
 (0)