mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Provide Selenium driver :timeout option for configuring the http client read timeout
This commit is contained in:
parent
321e903c4a
commit
79820165de
3 changed files with 18 additions and 2 deletions
|
@ -9,7 +9,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
clear_local_storage: nil,
|
||||
clear_session_storage: nil
|
||||
}.freeze
|
||||
SPECIAL_OPTIONS = %i[browser clear_local_storage clear_session_storage].freeze
|
||||
SPECIAL_OPTIONS = %i[browser clear_local_storage clear_session_storage timeout].freeze
|
||||
attr_reader :app, :options
|
||||
|
||||
def self.load_selenium
|
||||
|
@ -23,6 +23,9 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
|
||||
def browser
|
||||
@browser ||= begin
|
||||
if options[:timeout]
|
||||
options[:http_client] ||= Selenium::WebDriver::Remote::Http::Default.new(read_timeout: options[:timeout])
|
||||
end
|
||||
processed_options = options.reject { |key, _val| SPECIAL_OPTIONS.include?(key) }
|
||||
Selenium::WebDriver.for(options[:browser], processed_options).tap do |driver|
|
||||
specialize_driver(driver)
|
||||
|
|
|
@ -12,7 +12,7 @@ browser_options.headless! if ENV['HEADLESS']
|
|||
browser_options.add_option(:w3c, !!ENV['W3C'])
|
||||
|
||||
Capybara.register_driver :selenium_chrome do |app|
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options).tap do |driver|
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options, timeout: 30).tap do |driver|
|
||||
driver.browser.download_path = Capybara.save_path
|
||||
end
|
||||
end
|
||||
|
@ -71,6 +71,12 @@ RSpec.describe 'Capybara::Session with chrome' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'timeout' do
|
||||
it 'sets the http client read timeout' do
|
||||
expect(TestSessions::Chrome.driver.browser.send(:bridge).http.read_timeout).to eq 30
|
||||
end
|
||||
end
|
||||
|
||||
describe 'filling in Chrome-specific date and time fields with keystrokes' do
|
||||
let(:datetime) { Time.new(1983, 6, 19, 6, 30) }
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ Capybara.register_driver :selenium_firefox do |app|
|
|||
app,
|
||||
browser: :firefox,
|
||||
options: browser_options,
|
||||
timeout: 31,
|
||||
# Get a trace level log from geckodriver
|
||||
# :driver_opts => { args: ['-vv'] }
|
||||
)
|
||||
|
@ -146,6 +147,12 @@ RSpec.describe Capybara::Selenium::Driver do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'timeout' do
|
||||
it 'sets the http client read timeout' do
|
||||
expect(TestSessions::SeleniumFirefox.driver.browser.send(:bridge).http.read_timeout).to eq 31
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.describe Capybara::Selenium::Node do
|
||||
|
|
Loading…
Add table
Reference in a new issue