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

时间:2013-06-14 10:58:05

标签: c# webdriver selenium-webdriver

我想更改chrome的默认下载目录。我确实经历了以下网址中列出的不同论点 http://peter.sh/experiments/chromium-command-line-switches/

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

我想知道在chrome web driver C#中如何在运行时更改下载文件夹, 提前谢谢

1 个答案:

答案 0 :(得分:0)

试试这个。

   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);
    }
 }


}