Skip to content

Commit

Permalink
Add more Ruby bindings tests for page load timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Dec 8, 2019
1 parent 00de1c6 commit 81552aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def call(env)
end

[200, {'Content-Type' => 'text/html'}, [body]]
when '/sleep'
time = Rack::Request.new(env).params['time']
sleep Integer(time)
[200, {'Content-Type' => 'text/html'}, ["Slept for #{time}"]]
else
@static.call env
end
Expand Down
14 changes: 10 additions & 4 deletions rb/spec/integration/selenium/webdriver/timeout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ module WebDriver
end

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

it 'should be able to set the page load timeout' do
expect { driver.manage.timeouts.page_load = 2 }.not_to raise_exception
it 'should timeout if page takes too long to load' do
expect { driver.navigate.to url_for('sleep?time=3') }.to raise_error(WebDriver::Error::TimeoutError)
end

it 'should timeout if page takes too long to load after click' do
driver.navigate.to url_for('page_with_link_to_slow_loading_page.html')

expect { driver.find_element(id: 'link-to-slow-loading-page').click }.to raise_error(WebDriver::Error::TimeoutError)
end
end
end
Expand Down

0 comments on commit 81552aa

Please sign in to comment.