Reputation: 41
During the test, a file (.html) will be downloaded from the web application & I have to verify that file by opening it on the browser. In the non-headless mode, my test is working fine. But whenever I'm going to headless mode, that file is not getting downloaded to the download path (i.e. pointed in the "user.dir"). My chrome driver version is 2.44.609538 & selenium version is 3.14.
Upvotes: 4
Views: 4049
Reputation: 77
I met same situation.
Headless mode is very faster. So your code might be implemented to detect download(DL).
I implemented the above mechanism using callback function.
Upvotes: 0
Reputation: 1748
This worked for our ruby implementation:
Capybara.register_driver :scrapping_driver do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--disable-popup-blocking')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--window-size=1366,2000')
options.add_preference(:download, directory_upgrade: true,
prompt_for_download: false,
default_directory: "#{Rails.root}/")
options.add_preference(:browser, set_download_behavior: { behavior: 'allow' })
Selenium::WebDriver::Service.driver_path = Webdrivers::Chromedriver.driver_path
driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
Pay attention at download behaviour
Upvotes: 0
Reputation: 8444
Are you running the test from the command line?
Because, according to an answer to this question and this, when you run it via command line, your user.dir
corresponds to your global user directory (C:\users\username).
Upvotes: 0
Reputation: 187
Apparently this could help you
Shawn Button post the answer related with it.
Downloading with chrome headless and selenium
Upvotes: 2