7
這是我的解決方案,我在參考: How to set Chrome preferences using Selenium Webdriver .NET binding?C#設置默認的下載目錄chrome WebDriver?
但沒有工作,我需要谷歌瀏覽器更改默認下載目錄
C:\ TEMP \
感謝幫助。
public class ChromeOptionsWithPrefs : ChromeOptions
{
public Dictionary<string, object> prefs { get; set; }
}
public static void Initialize()
{
var options = new ChromeOptionsWithPrefs
{
prefs = new Dictionary<string, object>
{
{"download.default_directory", @"C:\temp\"}
}
};
RemoteWebDriver driver = new ChromeDriver(@"D:\chromedriver_win32\", options);
var download = driver.FindElements(By.XPath("//a[.='Download']"));
foreach (var t in download)
{
t.SendKeys(Keys.Enter);
}
}
林瑤池這種解決方案,它的工作
var chromeOptions = new ChromeOptions();
chromeOptions.AddUserProfilePreference("download.default_directory", @"D:\DataTest");
chromeOptions.AddUserProfilePreference("intl.accept_languages", "nl");
chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true");
var driver = new ChromeDriver(@"D:\chromedriver_win32\", chromeOptions);
var download = driver.FindElements(By.XPath("//a[.='ダウンロード']"));
foreach (var t in download)
{
t.SendKeys(Keys.Enter);
}
你不給的問題,你的答案。只需將其添加爲答案.. – Adarsha
重複的問題在這裏https://stackoverflow.com/questions/33434443/download-file-at-custom-path-using-selenium-webdriver –