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?