Skip to content

Commit

Permalink
[js] Add windowTypes option support for ChromiumDriver (#7897)
Browse files Browse the repository at this point in the history
* [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]>
  • Loading branch information
3 people authored Apr 20, 2021
1 parent 8aafd3f commit 18c9454
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions javascript/node/selenium-webdriver/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <webview> elements, include "webview" in the list.
* @param {...(string|!Array<string>)} 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.
Expand Down
18 changes: 18 additions & 0 deletions javascript/node/selenium-webdriver/test/chrome/options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 18c9454

Please sign in to comment.