Skip to content

Commit 36e0213

Browse files
authored
[ruby][bidi] Add test for using BiDi to navigate and get exceptions
1 parent 8a60fea commit 36e0213

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

rb/spec/integration/selenium/webdriver/bidi_spec.rb

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,37 @@
2222
module Selenium
2323
module WebDriver
2424
describe BiDi, exclusive: {browser: %i[chrome firefox]} do
25+
before do
26+
quit_driver
27+
create_driver!(web_socket_url: true)
28+
end
29+
2530
it 'gets session status' do
26-
reset_driver!(web_socket_url: true) do |driver|
27-
status = driver.bidi.session.status
28-
expect(status).to respond_to(:ready)
29-
expect(status.message).not_to be_empty
30-
end
31+
status = driver.bidi.session.status
32+
expect(status).to respond_to(:ready)
33+
expect(status.message).not_to be_empty
34+
end
35+
36+
it 'can navigate and listen to errors' do
37+
log_entry = nil
38+
log_inspector = BiDi::LogInspector.new(driver)
39+
log_inspector.on_javascript_exception { |log| log_entry = log }
40+
41+
browsing_context = BiDi::BrowsingContext.new(driver: driver, browsing_context_id: driver.window_handle)
42+
info = browsing_context.navigate(url: url_for('/bidi/logEntryAdded.html'))
43+
44+
expect(browsing_context.id).not_to be_nil
45+
expect(info.navigation_id).to be_nil
46+
expect(info.url).to include('/bidi/logEntryAdded.html')
47+
48+
driver.find_element(id: 'jsException').click
49+
wait.until { !log_entry.nil? }
50+
51+
expect(log_entry).to have_attributes(
52+
text: "Error: Not working",
53+
type: "javascript",
54+
level: BiDi::LogInspector::LOG_LEVEL[:ERROR]
55+
)
3156
end
3257
end
3358
end

0 commit comments

Comments
 (0)