Skip to content

Commit 92fbd13

Browse files
committed
speed up Ruby test devtools_spec.rb
instead of sleeping for 2.5s, just wait for the needed logs.
1 parent 2a4fe60 commit 92fbd13

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,20 @@ 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

106-
driver.execute_script("console.log('I like cheese');")
107-
sleep 0.5
108106
driver.execute_script('console.log(true);')
109-
sleep 0.5
110107
driver.execute_script('console.log(null);')
111-
sleep 0.5
112108
driver.execute_script('console.log(undefined);')
113-
sleep 0.5
114109
driver.execute_script('console.log(document);')
115-
sleep 0.5
110+
driver.execute_script("console.log('I like cheese');")
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?('I like cheese') }
113+
114+
expect(logs).to include(true)
115+
expect(logs).to include(nil)
116+
expect(logs).to include({'type' => 'undefined'})
123117
end
124118

125119
it 'notifies about document log messages' do

0 commit comments

Comments
 (0)