Skip to content

Commit 275cf06

Browse files
committed
speed up Ruby test devtools_spec.rb
instead of sleeping for 2.5s, just wait for the needed logs.
1 parent 188cef6 commit 275cf06

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

rb/spec/integration/selenium/webdriver/devtools_spec.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,19 @@ module WebDriver
100100

101101
it 'notifies about log messages' do
102102
logs = []
103-
driver.on_log_event(:console) { |log| logs.push(log) }
103+
driver.on_log_event(:console) { |log| logs.push(log.args[0]) }
104104
driver.navigate.to url_for('javascriptPage.html')
105105

106106
driver.execute_script("console.log('I like cheese');")
107-
sleep 0.5
108107
driver.execute_script('console.log(true);')
109-
sleep 0.5
110108
driver.execute_script('console.log(null);')
111-
sleep 0.5
112109
driver.execute_script('console.log(undefined);')
113-
sleep 0.5
114110
driver.execute_script('console.log(document);')
115-
sleep 0.5
116111

117-
expect(logs).to include(
118-
an_object_having_attributes(type: :log, args: ['I like cheese']),
119-
an_object_having_attributes(type: :log, args: [true]),
120-
an_object_having_attributes(type: :log, args: [nil]),
121-
an_object_having_attributes(type: :log, args: [{'type' => 'undefined'}])
122-
)
112+
wait.until { logs.include?(true) }
113+
wait.until { logs.include?(nil) }
114+
wait.until { logs.include?({'type' => 'undefined'}) }
115+
wait.until { logs.include?('I like cheese') }
123116
end
124117

125118
it 'notifies about document log messages' do

0 commit comments

Comments
 (0)