Skip to content

Commit 81552aa

Browse files
committed
Add more Ruby bindings tests for page load timeout
1 parent 00de1c6 commit 81552aa

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ def call(env)
116116
end
117117

118118
[200, {'Content-Type' => 'text/html'}, [body]]
119+
when '/sleep'
120+
time = Rack::Request.new(env).params['time']
121+
sleep Integer(time)
122+
[200, {'Content-Type' => 'text/html'}, ["Slept for #{time}"]]
119123
else
120124
@static.call env
121125
end

rb/spec/integration/selenium/webdriver/timeout_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ module WebDriver
7676
end
7777

7878
context 'page loads' do
79-
# w3c default is 300,000
80-
after { driver.manage.timeouts.page_load = 300000 }
79+
before { driver.manage.timeouts.page_load = 2 }
80+
after { driver.manage.timeouts.page_load = 300 }
8181

82-
it 'should be able to set the page load timeout' do
83-
expect { driver.manage.timeouts.page_load = 2 }.not_to raise_exception
82+
it 'should timeout if page takes too long to load' do
83+
expect { driver.navigate.to url_for('sleep?time=3') }.to raise_error(WebDriver::Error::TimeoutError)
84+
end
85+
86+
it 'should timeout if page takes too long to load after click' do
87+
driver.navigate.to url_for('page_with_link_to_slow_loading_page.html')
88+
89+
expect { driver.find_element(id: 'link-to-slow-loading-page').click }.to raise_error(WebDriver::Error::TimeoutError)
8490
end
8591
end
8692
end

0 commit comments

Comments
 (0)