Skip to content

Commit

Permalink
update specs so navigation completes before adding handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jun 4, 2024
1 parent 5b2c1d4 commit aeb7b85
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions rb/spec/integration/selenium/webdriver/bidi/script_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ module WebDriver
end

it 'logs console messages' do
log_entries = []
driver.navigate.to url_for('bidi/logEntryAdded.html')

log_entries = []
driver.script.add_console_message_handler { |log| log_entries << log }
driver.navigate.to url_for('bidi/logEntryAdded.html')

driver.find_element(id: 'jsException').click
driver.find_element(id: 'consoleLog').click
Expand All @@ -53,41 +53,45 @@ module WebDriver
end

it 'logs multiple console messages' do
log_entries = []
driver.navigate.to url_for('bidi/logEntryAdded.html')

log_entries = []
driver.script.add_console_message_handler { |log| log_entries << log }
driver.script.add_console_message_handler { |log| log_entries << log }
driver.navigate.to url_for('bidi/logEntryAdded.html')

driver.find_element(id: 'jsException').click
driver.find_element(id: 'consoleLog').click
driver.find_element(id: 'consoleLog').click

wait.until { log_entries.size > 1 }
expect(log_entries.size).to eq(2)
end

it 'logs removes console message handler' do
log_entries = []
driver.navigate.to url_for('bidi/logEntryAdded.html')

log_entries = []
id = driver.script.add_console_message_handler { |log| log_entries << log }
driver.script.add_console_message_handler { |log| log_entries << log }
driver.navigate.to url_for('bidi/logEntryAdded.html')

driver.find_element(id: 'consoleLog').click

wait.until { log_entries.size > 1 }

driver.script.remove_console_message_handler(id)

driver.find_element(id: 'consoleLog').click

wait.until { log_entries.size > 2 }
expect(log_entries.size).to eq(3)
end

it 'logs javascript errors' do
log_entries = []
driver.navigate.to url_for('bidi/logEntryAdded.html')

log_entries = []
driver.script.add_javascript_error_handler { |log| log_entries << log }
driver.navigate.to url_for('bidi/logEntryAdded.html')

driver.find_element(id: 'consoleLog').click
driver.find_element(id: 'jsException').click

Expand Down

0 comments on commit aeb7b85

Please sign in to comment.