2016-02-17 4 views
7

Dies ist meine Lösung, ich bin Bezug auf: How to set Chrome preferences using Selenium Webdriver .NET binding?C# Standard-Download-Verzeichnis Chrome WebDriver festlegen?

Aber nicht funktioniert, ich brauche für Google Chrome

C Standard-Download-Verzeichnis ändern: \

\ temp Danke für die Hilfe.

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

Im finded diese Lösung, es

arbeitete Einfügen
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); 

     } 
+2

Sie nicht Ihre Antworten in der Frage geben. Fügen Sie es einfach als Antwort .. – Adarsha

+0

doppelte Frage hier https://stackoverflow.com/questions/33434443/download-file-at-custom-path-using-selenium-webdriver –

Antwort

6

nur die Antwort, dass OP gefunden, aber als Antwort nicht hinzufügen.

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

gearbeitet Diese Einstellungen für mich

var chromeOptions = new ChromeOptions(); 
var downloadDirectory = "C:\Temp"; 

chromeOptions.AddUserProfilePreference("download.default_directory", downloadDirectory); 
chromeOptions.AddUserProfilePreference("download.prompt_for_download", false); 
chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true"); 

var driver = new ChromeDriver(chromeOptions); 
Verwandte Themen