Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rb/lib/selenium/webdriver/bidi/browsing_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: n
params = {context: context_id, viewport: {width:, height:}, device_pixel_ratio:}
@bidi.send_cmd('browsingContext.setViewport', **params)
end

def activate(context_id: nil)
context_id ||= @bridge.window_handle
@bidi.send_cmd('browsingContext.activate', context: context_id)
end
end
end # BiDi
end # WebDriver
Expand Down
2 changes: 2 additions & 0 deletions rb/sig/lib/selenium/webdriver/bidi/browsing_context.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module Selenium

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

def activate: (String? context_id) -> Hash[nil, nil]

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

def set_viewport: (String context_id, Integer width, Integer height, Float device_pixel_ratio) -> Hash[nil, nil]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ class BiDi
expect(driver.execute_script('return window.devicePixelRatio')).to eq(2.0)
end
end

it 'activates a browser context' do
reset_driver!(web_socket_url: true) do |driver|
browsing_context = described_class.new(driver)
browsing_context.create

expect(driver.execute_script('return document.hasFocus();')).to be_falsey
browsing_context.activate
expect(driver.execute_script('return document.hasFocus();')).to be_truthy
end
end
end
end # BiDi
end # WebDriver
Expand Down
Loading