After updating past Chromium 127, running RSpec tests on PDF downloads now uniformly time out. We use this somewhat popular helper code to yield the download after clicking a PDF link:
module DownloadHelpers
TIMEOUT = 10
PATH = Capybara.save_path
module_function
def downloads
Dir[PATH.join('*.{pdf,csv}')]
end
def download
downloads.first
end
def download_content
wait_for_download
File.read(download)
end
def wait_for_download
Timeout.timeout(TIMEOUT) do
sleep 0.1 until downloaded?
end
end
def downloaded?
!downloading? && downloads.any?
end
def downloading?
downloads.grep(/\.crdownload$/).any?
end
def clear_downloads
FileUtils.rm_f(downloads)
end
end
RSpec.configure do |config|
config.include DownloadHelpers, type: :system
config.before(:each, type: :system) do
clear_downloads
end
config.after(:each, type: :system) do
clear_downloads
end
end
Waiting for a PDF download just hangs indefinitely. Watching with headless turned off, the PDF will never load in the new tab, however, trying this manually on a clean instance of Chromium will load the PDF perfectly. Perhaps an upstream regression with the CDP? Maybe also related: https://github.com/rubycdp/ferrum/discussions/457#discussioncomment-9151778
After updating past Chromium 127, running RSpec tests on PDF downloads now uniformly time out. We use this somewhat popular helper code to yield the download after clicking a PDF link:
Waiting for a PDF download just hangs indefinitely. Watching with headless turned off, the PDF will never load in the new tab, however, trying this manually on a clean instance of Chromium will load the PDF perfectly. Perhaps an upstream regression with the CDP? Maybe also related: https://github.com/rubycdp/ferrum/discussions/457#discussioncomment-9151778