Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rb] Fix BiDi tests errors #15482

Merged
merged 1 commit into from
Mar 22, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ class BiDi
expect(driver.window_handles).to include(id)
end

it 'errors on unknown type' do
it 'errors on unknown type', except: {browser: :firefox, reason: "Doesn't return the expected error"} do
msg = /invalid argument: Invalid enum value. Expected 'tab' | 'window', received 'unknown'/
expect {
described_class.new(bridge).create(type: :unknown)
@@ -75,41 +75,52 @@ class BiDi
end

it 'sets the viewport' do
browsing_context = described_class.new(driver)
browsing_context = described_class.new(bridge)
browsing_context.set_viewport(width: 800, height: 600, device_pixel_ratio: 2.0)
expect(driver.execute_script('return [window.innerWidth, window.innerHeight]')).to eq([800, 600])
expect(driver.execute_script('return window.devicePixelRatio')).to eq(2.0)
end

it 'accepts users prompts without text' do
browsing_context = described_class.new(driver)
window = browsing_context.create
browsing_context = described_class.new(bridge)

driver.navigate.to url_for('alerts.html')
driver.find_element(id: 'alert').click
wait.until { driver.switch_to.alert }
window = driver.window_handles.first
browsing_context.handle_user_prompt(window, accept: true)
wait_for_no_alert

expect(driver.page_source).to include('hello')
expect(driver.title).to eq('Testing Alerts')
end

it 'accepts users prompts with text' do
browsing_context = described_class.new(driver)
window = browsing_context.create

browsing_context = described_class.new(bridge)
driver.navigate.to url_for('alerts.html')
driver.find_element(id: 'prompt').click
wait_for_alert
window = driver.window_handles.first
browsing_context.handle_user_prompt(window, accept: true, text: 'Hello, world!')
wait_for_no_alert

expect(driver.page_source).to include('hello')
expect(driver.title).to eq('Testing Alerts')
end

it 'rejects users prompts' do
browsing_context = described_class.new(driver)
window = browsing_context.create
browsing_context = described_class.new(bridge)
driver.navigate.to url_for('alerts.html')
driver.find_element(id: 'alert').click
wait_for_alert
window = driver.window_handles.first

browsing_context.handle_user_prompt(window, accept: false)
wait_for_no_alert

expect(driver.page_source).to include('goodbye')
expect(driver.title).to eq('Testing Alerts')
end

it 'activates a browser context' do
browsing_context = described_class.new(driver)
browsing_context = described_class.new(bridge)
browsing_context.create

expect(driver.execute_script('return document.hasFocus();')).to be_falsey
2 changes: 2 additions & 0 deletions rb/spec/integration/selenium/webdriver/bidi/network_spec.rb
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@ module WebDriver
class BiDi
describe Network, exclusive: {bidi: true, reason: 'only executed when bidi is enabled'},
only: {browser: %i[chrome edge firefox]} do
after { |example| reset_driver!(example: example) }

it 'adds an intercept' do
network = described_class.new(driver.bidi)
intercept = network.add_intercept(phases: [described_class::PHASES[:before_request]])