Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8c317d8
[build] allow tests tagged exclusive-if-local to run on rbe
titusfortner Mar 22, 2025
bb29c66
merge trunk
aguspe Apr 2, 2025
5b6a0ce
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 22, 2025
c9cb77c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 30, 2025
ac9a80e
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 18, 2025
aef922a
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 24, 2025
8dc6cfc
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jun 7, 2025
16dc0d3
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jun 13, 2025
85fdc1c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jul 14, 2025
72bf4ec
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Aug 2, 2025
81f2331
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Aug 9, 2025
d03e95b
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Aug 19, 2025
61a54ce
Add get windows for ruby bindings
aguspe Aug 19, 2025
0c872c4
Merge branch 'trunk' into rb_bidi_get_client_windows
aguspe Sep 4, 2025
77f3bc1
Remove firefox and investigate support for feature afterwards
aguspe Sep 4, 2025
743ccf9
Remove log
aguspe Sep 4, 2025
1fca07d
Merge branch 'trunk' into rb_bidi_get_client_windows
aguspe Sep 4, 2025
d2291fb
update guards
aguspe Sep 4, 2025
f8c41f8
Merge remote-tracking branch 'origin/rb_bidi_get_client_windows' into…
aguspe Sep 4, 2025
3cd960f
Merge branch 'trunk' into rb_bidi_get_client_windows
aguspe Sep 6, 2025
c0a0c8f
update guards
aguspe Sep 6, 2025
4005695
Merge remote-tracking branch 'origin/rb_bidi_get_client_windows' into…
aguspe Sep 6, 2025
8dc8b5e
update guards
aguspe Sep 6, 2025
2927a8f
modify expectations
aguspe Sep 6, 2025
d52f08b
modify guards
aguspe Sep 6, 2025
f168acf
fix test
aguspe Sep 6, 2025
644ad63
validate firefox
aguspe Sep 6, 2025
bf45af7
try to fix tests
aguspe Sep 7, 2025
2f5c9be
fix guard
aguspe Sep 8, 2025
8a426e9
Merge branch 'trunk' into rb_bidi_get_client_windows
aguspe Sep 8, 2025
9190773
fix guard
aguspe Sep 8, 2025
847eedc
Merge remote-tracking branch 'origin/rb_bidi_get_client_windows' into…
aguspe Sep 8, 2025
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
24 changes: 23 additions & 1 deletion rb/lib/selenium/webdriver/bidi/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ module Selenium
module WebDriver
class BiDi
class Browser
Window = Struct.new(:handle, :active, :height, :width, :x, :y, :state) do
def active?
active
end
end
def initialize(bidi)
@bidi = bidi
end
Expand All @@ -36,7 +41,24 @@ def user_contexts
def remove_user_context(user_context)
@bidi.send_cmd('browser.removeUserContext', userContext: user_context)
end
end

def windows
response = @bidi.send_cmd('browser.getClientWindows')

response['clientWindows'].map do |win_data|
attributes = {
handle: win_data['clientWindow'],
active: win_data['active'],
height: win_data['height'],
width: win_data['width'],
x: win_data['x'],
y: win_data['y'],
state: win_data['state']
}
Window.new(**attributes)
end
end
end # Browser
end # BiDi
end # WebDriver
end # Selenium
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/bidi/browsing_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def activate(context_id: nil)
context_id ||= @bridge.window_handle
@bidi.send_cmd('browsingContext.activate', context: context_id)
end
end
end # BrowsingContext
end # BiDi
end # WebDriver
end # Selenium
2 changes: 2 additions & 0 deletions rb/sig/lib/selenium/webdriver/bidi/browser.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Selenium
module WebDriver
class BiDi
class Browser
Window: Selenium::WebDriver::BiDi::Browser::Window

@bidi: BiDi

def initialize: (BiDi bidi) -> void
Expand Down
13 changes: 7 additions & 6 deletions rb/spec/integration/selenium/webdriver/action_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ module WebDriver
expect(driver.find_element(id: 'result').text.strip).to be_empty
end

it 'sends keys to element' do
it 'sends keys to element', only: {browser: %i[chrome edge firefox]} do
driver.navigate.to url_for('formPage.html')

input = driver.find_element(css: '#working')
driver.execute_script('arguments[0].scrollIntoView({block: "center", inline: "nearest"});', input)

driver.action.send_keys(input, 'abcd').perform
wait.until { input.property(:value).length == 4 }
Expand Down Expand Up @@ -305,9 +306,9 @@ module WebDriver
end
end

describe '#scroll_to', only: {browser: %i[chrome edge firefox]} do
describe '#scroll_to' do
it 'scrolls to element',
except: {browser: :firefox, reason: 'incorrect MoveTargetOutOfBoundsError'} do
exclusive: {browser: %i[chrome edge], reason: 'incorrect MoveTargetOutOfBoundsError'} do
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
iframe = driver.find_element(tag_name: 'iframe')

Expand All @@ -321,7 +322,7 @@ module WebDriver

describe '#scroll_by' do
it 'scrolls by given amount',
exclude: {driver: :firefox, reason: 'inconsistent behavior between versions'} do
exclusive: {browser: %i[chrome edge], reason: 'inconsistent behavior between versions'} do
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
footer = driver.find_element(tag_name: 'footer')
delta_y = footer.rect.y.round
Expand All @@ -335,7 +336,7 @@ module WebDriver

describe '#scroll_from' do
it 'scrolls from element by given amount',
except: {browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'} do
exclusive: {browser: %i[chrome edge], reason: 'incorrect MoveTargetOutOfBoundsError in Firefox'} do
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
iframe = driver.find_element(tag_name: 'iframe')
scroll_origin = WheelActions::ScrollOrigin.element(iframe)
Expand All @@ -349,7 +350,7 @@ module WebDriver
end

it 'scrolls from element by given amount with offset',
except: {browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'} do
exclusive: {browser: %i[chrome edge], reason: 'incorrect MoveTargetOutOfBoundsError in Firefox'} do
driver.navigate.to url_for('scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html')
footer = driver.find_element(tag_name: 'footer')
scroll_origin = WheelActions::ScrollOrigin.element(footer, 0, -50)
Expand Down
64 changes: 33 additions & 31 deletions rb/spec/integration/selenium/webdriver/bidi/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,54 @@ module WebDriver
class BiDi
describe Browser, exclusive: {bidi: true, reason: 'only executed when bidi is enabled'},
only: {browser: %i[chrome edge firefox]} do
after { |example| reset_driver!(example: example) }

let(:bidi) { driver.bidi }

it 'creates an user context' do
reset_driver!(web_socket_url: true) do |driver|
browser = described_class.new(driver.bidi)
user_context = browser.create_user_context
expect(user_context).not_to be_nil
expect(user_context['userContext']).to be_a String
end
browser = described_class.new(bidi)
user_context = browser.create_user_context
expect(user_context).not_to be_nil
expect(user_context['userContext']).to be_a String
end

it 'gets user contexts' do
reset_driver!(web_socket_url: true) do |driver|
browser = described_class.new(driver.bidi)
created_context_id = browser.create_user_context['userContext']
all_context_ids = browser.user_contexts['userContexts'].map { |c| c['userContext'] }
browser = described_class.new(bidi)
created_context_id = browser.create_user_context['userContext']
all_context_ids = browser.user_contexts['userContexts'].map { |c| c['userContext'] }

expect(all_context_ids).to include(created_context_id)
end
expect(all_context_ids).to include(created_context_id)
end

it 'removes an user context' do
reset_driver!(web_socket_url: true) do |driver|
browser = described_class.new(driver.bidi)
context_id_to_remove = browser.create_user_context['userContext']
browser.remove_user_context(context_id_to_remove)
all_ids_after_removal = browser.user_contexts['userContexts'].map { |c| c['userContext'] }
browser = described_class.new(bidi)
context_id_to_remove = browser.create_user_context['userContext']
browser.remove_user_context(context_id_to_remove)
all_ids_after_removal = browser.user_contexts['userContexts'].map { |c| c['userContext'] }

expect(all_ids_after_removal).not_to include(context_id_to_remove)
end
expect(all_ids_after_removal).not_to include(context_id_to_remove)
end

it 'throws an error when removing the default user context' do
reset_driver!(web_socket_url: true) do |driver|
browser = described_class.new(driver.bidi)
expect {
browser.remove_user_context('default')
}.to raise_error(Error::WebDriverError, /user context cannot be removed/)
end
browser = described_class.new(bidi)
expect {
browser.remove_user_context('default')
}.to raise_error(Error::WebDriverError, /user context cannot be removed/)
end

it 'throws an error when removing a non-existent user context' do
reset_driver!(web_socket_url: true) do |driver|
browser = described_class.new(driver.bidi)
expect {
browser.remove_user_context('fake_context')
}.to raise_error(Error::WebDriverError)
end
browser = described_class.new(bidi)
expect {
browser.remove_user_context('fake_context')
}.to raise_error(Error::WebDriverError)
end

it 'get windows' do
browser = described_class.new(bidi)
windows = browser.windows
active_window = windows.first

expect(active_window).to be_a(Selenium::WebDriver::BiDi::Browser::Window)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module WebDriver
expect(new_rect.height).to eq(target_height)
end

it 'can maximize the current window' do
it 'can maximize the current window', except: {browser: :firefox, platform: :macosx} do
window.size = old_size = Dimension.new(700, 700)

window.maximize
Expand Down
Loading