Skip to content

Commit d35affc

Browse files
committed
Fix conflicts
2 parents c2c9fec + 014129f commit d35affc

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

rb/lib/selenium/webdriver/bidi/browsing_context.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: n
101101
@bidi.send_cmd('browsingContext.setViewport', **params)
102102
end
103103

104+
def handle_user_prompt(context_id, accept: true, text: nil)
105+
@bidi.send_cmd('browsingContext.handleUserPrompt', context: context_id, accept: accept, text: text)
106+
end
107+
104108
def activate(context_id: nil)
105109
context_id ||= @bridge.window_handle
106110
@bidi.send_cmd('browsingContext.activate', context: context_id)

rb/sig/lib/selenium/webdriver/bidi/browsing_context.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Selenium
88

99
def initialize: (Remote::Bridge bridge) -> void
1010

11+
def handle_user_prompt: (String context, bool accept, String text) -> untyped
12+
1113
def activate: (String? context_id) -> Hash[nil, nil]
1214

1315
def navigate: (String url, String? context_id) -> void

rb/spec/integration/selenium/webdriver/bidi/browsing_context_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,39 @@ class BiDi
8383
end
8484
end
8585

86+
it 'accepts users prompts without text' do
87+
reset_driver!(web_socket_url: true) do |driver|
88+
browsing_context = described_class.new(driver)
89+
window = browsing_context.create
90+
91+
browsing_context.handle_user_prompt(window, accept: true)
92+
93+
expect(driver.page_source).to include('hello')
94+
end
95+
end
96+
97+
it 'accepts users prompts with text' do
98+
reset_driver!(web_socket_url: true) do |driver|
99+
browsing_context = described_class.new(driver)
100+
window = browsing_context.create
101+
102+
browsing_context.handle_user_prompt(window, accept: true, text: 'Hello, world!')
103+
104+
expect(driver.page_source).to include('hello')
105+
end
106+
end
107+
108+
it 'rejects users prompts' do
109+
reset_driver!(web_socket_url: true) do |driver|
110+
browsing_context = described_class.new(driver)
111+
window = browsing_context.create
112+
113+
browsing_context.handle_user_prompt(window, accept: false)
114+
115+
expect(driver.page_source).to include('goodbye')
116+
end
117+
end
118+
86119
it 'activates a browser context' do
87120
reset_driver!(web_socket_url: true) do |driver|
88121
browsing_context = described_class.new(driver)

0 commit comments

Comments
 (0)