更改默认的chrome下载文件夹webdriver c#

本文关键字:文件夹 webdriver 下载 chrome 默认 | 更新日期: 2023-09-27 18:18:37

我想更改chrome的默认下载目录。我检查了下面url
中列出的不同参数http://peter.sh/experiments/chromium-command-line-switches/

http://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches

我想知道如何在chrome web驱动程序c#运行时更改下载文件夹,提前谢谢大家

更改默认的chrome下载文件夹webdriver c#

试试这个。

   namespace UnitTestProject1_webdriver
{
public class ChromeOptionsWithPrefs : ChromeOptions
{
    public Dictionary<string, object> prefs { get; set; }
}
[TestClass]
public class demo
 {
    [TestMethod]
    public void demo1()
    {var options = new ChromeOptionsWithPrefs();
        options.prefs = new Dictionary<string, object>
        {
            { "download.default_directory", @"c:'download temp'" }
        };
        RemoteWebDriver driver = new ChromeDriver(@"d:'selenium dlls'", options);
    }
 }

}