Skip to content

Commit 6222ac0

Browse files
committed
[rb] Adding support for webview2 in Edge
Fixes #11978
1 parent cf81dea commit 6222ac0

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

rb/lib/selenium/webdriver/edge/options.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ class Options < Chromium::Options
2626
KEY = 'ms:edgeOptions'
2727
BROWSER = 'MicrosoftEdge'
2828

29+
#
30+
# Changes the browser name enable webview2
31+
# see: https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver
32+
# Automation of WebView2 apps with Microsoft Edge WebDriver
33+
#
34+
# @example Enable webview2
35+
# options = Selenium::WebDriver::Edge::Options.new
36+
# options.webview2!
37+
#
38+
39+
def webview2!
40+
@options[:browser_name] = 'webview2'
41+
end
42+
2943
private
3044

3145
def enable_logging(browser_options)

rb/spec/unit/selenium/webdriver/edge/options_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ module Edge
169169
end
170170
end
171171

172+
describe 'uses webview2 for MS Edge Driver' do
173+
it 'changes browserName to webview2' do
174+
options.webview2!
175+
expect(options.browser_name).to eq('webview2')
176+
end
177+
end
178+
172179
describe '#add_preference' do
173180
it 'adds a preference' do
174181
options.add_preference(:foo, 'bar')

0 commit comments

Comments
 (0)