Module: SeleniumDownloadHelper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/selenium_download_helper.rb,
lib/selenium_download_helper/errors.rb,
lib/selenium_download_helper/version.rb
Defined Under Namespace
Classes: TimeoutError
Constant Summary collapse
- TEMPORARY_DOWNLOAD_FILENAME_PATTERN =
/(\.crdownload|^downloads.html)$/- VERSION =
'1.2.1'
Instance Method Summary collapse
Instance Method Details
#wait_for_downloaded(timeout: 10, interval: 0.2, all: false, filename: nil, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/selenium_download_helper.rb', line 22 def wait_for_downloaded(timeout: 10, interval: 0.2, all: false, filename: nil, &block) download_path= mkdownloaddir page.driver.browser.download_path = download_path yield Selenium::WebDriver::Wait.new(timeout: timeout, interval: interval).until { downloaded?(download_path, filename:) } downloaded_files(download_path, filename:).then { |files| all ? files : files.first } rescue Selenium::WebDriver::Error::TimeoutError => e raise TimeoutError.new(e, download_path) end |