3

The only way that I've found to enable downloads in Headless Chrome is with the following code:

 var param = new Dictionary<string, object>();
 param.Add("behavior", "allow");
 param.Add("downloadPath", $"C:\\Users\\{Environment.UserName}\\Downloads\\");
 driver.ExecuteChromeCommand("Page.setDownloadBehavior", param);

However, when using Selenium Grid, the driver must be initialized as RemoteWebDriver:

driver = new RemoteWebDriver(new Uri(url), options);

RemoteWebDriver doesn't have the ExecuteChromeCommand method and it can't be cast to ChromeDriver ((ChromeDriver)driver throws an exception).

Therefore, how can I enable downloads in headless chrome when using Selenium Grid?

Jack
  • 241
  • 2
  • 14
  • This answer might point you in the right direction: https://stackoverflow.com/questions/47068912/how-to-download-a-file-using-the-remote-selenium-webdriver – CEH Sep 24 '19 at 15:46

0 Answers0