0

I have found code snippets in java script and in python on how to enable downloading of files in headless mode using the chrome driver. However I am unsure on how to replicate the lines of code to run using VBA (Im using excel in particular)

I've tried these settings so far

driver.SetPreference "download.prompt_for_download", False
driver.SetPreference "download.directory_upgrade", True
driver.SetPreference "download.default_directory", FLDR_NAME
driver.SetPreference "safebrowsing.enabled", False
driver.SetPreference "download.prompt_for_download", False
driver.SetPreference "download.setdownloadbehaviour", "allow"
driver.SetPreference "safebrowsing.disable_download_protection", True

This was an attempt at copying the javascript version of downloading in headless mode below

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_experimental_option("prefs", {
  "download.default_directory": "/path/to/download/dir",
  "download.prompt_for_download": False,
})

chrome_options.add_argument("--headless")
driver = webdriver.Chrome(chrome_options=chrome_options)

driver.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
params = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': "/path/to/download/dir"}}
command_result = driver.execute("send_command", params)

When my automation runs in headless mode, gets to the point of downloading. It successfully clicks the download link but the download does not commence. There is no error and the screenshot shows nothing else has happened. When I run the exact same code without headless mode it works perfectly.

  • Does [this](https://stackoverflow.com/questions/57599776/download-file-through-google-chrome-in-headless-mode/57606294#57606294) helps you? – undetected Selenium Sep 03 '19 at 10:52
  • I'm getting an error that the session cannot be created as chromedriver only supports Chrome Version 77. Unfortunately I'm on my work has blocked downloading/updating Chrome downloading newer version of chrome onto our PC. – Boitumelo Mogajane Sep 04 '19 at 05:04

0 Answers0