Skip to content

Commit 737c1cc

Browse files
committed
[javascript] Adding userWebView2 to JS
#11978
1 parent 38b4acc commit 737c1cc

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

java/src/org/openqa/selenium/edge/EdgeOptions.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ public EdgeOptions() {
5555
super(CapabilityType.BROWSER_NAME, EDGE.browserName(), CAPABILITY);
5656
}
5757

58-
public void useWebView(boolean webViewEnabled) {
59-
String browserName = webViewEnabled ? WEBVIEW2_BROWSER_NAME : EDGE.browserName();
58+
/**
59+
* Changes the browser name to 'webview2' to enable
60+
* <a href="https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver">
61+
* test automation of WebView2 apps with Microsoft Edge WebDriver
62+
* </a>
63+
*
64+
* @param enable boolean flag to enable or disable the 'webview2' usage
65+
*/
66+
public void useWebView(boolean enable) {
67+
String browserName = enable ? WEBVIEW2_BROWSER_NAME : EDGE.browserName();
6068
setCapability(CapabilityType.BROWSER_NAME, browserName);
6169
}
6270

javascript/node/selenium-webdriver/edge.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@ class Options extends chromium.Options {
127127
setEdgeChromiumBinaryPath(path) {
128128
return this.setBinaryPath(path)
129129
}
130+
131+
/**
132+
* Changes the browser name to 'webview2' to enable
133+
* <a href="https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver">
134+
* test automation of WebView2 apps with Microsoft Edge WebDriver
135+
* </a>
136+
*
137+
* @param {boolean} enable flag to enable or disable the 'webview2' usage
138+
*/
139+
useWebView(enable) {
140+
const browserName = enable ? 'webview2' : Browser.EDGE;
141+
return this.setBrowserName(browserName);
142+
}
130143
}
131144

132145
/**

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ describe('edge.Options', function () {
6161
},
6262
})
6363
})
64+
65+
it('useWebView changes browser name', function () {
66+
let options = new edge.Options()
67+
assert.strictEqual(options.getBrowserName(), 'MicrosoftEdge')
68+
options.useWebView(true)
69+
assert.strictEqual(options.getBrowserName(), 'webview2')
70+
options.useWebView(false)
71+
assert.strictEqual(options.getBrowserName(), 'MicrosoftEdge')
72+
})
6473
})
6574

6675
describe('addExtensions', function () {

0 commit comments

Comments
 (0)