|
|
|
|
|
by vadansky
3275 days ago
|
|
>One thing I learned and wanted to warn about here is that Chrome headless currently doesn't support file downloads [1]. Not true. At least with C# You can use var client = new WebClient();
client.Headers[HttpRequestHeader.Cookie] = cookieString(driver);
client.DownloadFile(reportURL, savePath + fileName + ".xlsx");
Along with: string cookieString(IWebDriver driver)
{
var cookies = driver.Manage().Cookies.AllCookies;
return string.Join("; ", cookies.Select(c => string.Format("{0}={1}", c.Name, c.Value)));
}
Edit: Just wanted to emphasize that this ensures all the steps you did to login won't be lost since you're using the logged in cookie.
The idea is to use Selenium to get the download url and then use a regular download method using the selenium cookie. |
|
(otherwise you could use pretty much whatever you want to download the file, indeed).