Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Selenium驱动程序在保存文件时出现问题_C#_Selenium_Google Chrome_Selenium Chromedriver - Fatal编程技术网

C# Selenium驱动程序在保存文件时出现问题

C# Selenium驱动程序在保存文件时出现问题,c#,selenium,google-chrome,selenium-chromedriver,C#,Selenium,Google Chrome,Selenium Chromedriver,在初始化chrome驱动程序时,我给出了默认文件路径,但不是保存在默认位置,而是保存在下载文件夹。我还更改了chrome设置中的默认值,但它仍然保存在下载文件夹中 ChromeOptions chrome = new ChromeOptions(); _chromeDriverService = ChromeDriverService.CreateDefaultService(_config.ReadConfig(VanityRedirect_Co

在初始化chrome驱动程序时,我给出了默认文件路径,但不是保存在默认位置,而是保存在下载文件夹。我还更改了chrome设置中的默认值,但它仍然保存在下载文件夹中

            ChromeOptions chrome = new ChromeOptions();
            _chromeDriverService = ChromeDriverService.CreateDefaultService(_config.ReadConfig(VanityRedirect_Constants.ChromeFilePath));
            _chromeDriverService.HideCommandPromptWindow = false;
            chrome.AddArguments("--test-type");
            chrome.AddArgument("--start-maximized");
            chrome.AddArguments("--disable-extensions");
            chrome.AddUserProfilePreference("download.prompt_for_download", true);
            chrome.AddUserProfilePreference("download.directory_upgrade", true);
            chrome.AddUserProfilePreference("download.default_directory", "Some Path");
            chrome.AddUserProfilePreference("safebrowsing.enabled", false);
            _driver = new ChromeDriver(_chromeDriverService, chrome, VanityRedirect_Constants.ChromeLoadTimeVanity); 
有人能帮我解决这个问题吗

上述代码在一台服务器上运行良好,但可以在另一台服务器的特定路径上下载。 它正在打开一个windows对话框,我正在为它提供一条路径。现在在一台服务器上,它在给定的路径上下载,但一旦在另一台服务器上使用相同的代码,它只在下载路径上下载。 我想这是一个新问题,无法找到解决方案。请帮帮我。
提前谢谢。

我不知道c语言的确切语法,但java代码就是这样

对于Chromedriver,请尝试:

String downloadFilePath = "/path/to/download";
HashMap<String, Object> chromePref = new HashMap<String, Object>();
chromePref.put("profile.default_content_settings.popups", 0);
chromePref.put("download.default_directory", downloadFilePath );
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePref);
DesiredCapabilities des_cap = DesiredCapabilities.chrome();
des_cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
des_cap.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(des_cap);
String downloadFilePath=“/path/to/download”;
HashMap chromePref=新HashMap();
chromePref.put(“profile.default\u content\u settings.popups”,0);
chromePref.put(“download.default_目录”,downloadFilePath);
ChromeOptions选项=新的ChromeOptions();
选项。设置实验选项(“prefs”,chromePref);
DesiredCapabilities des_cap=DesiredCapabilities.chrome();
des_cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS,true);
des_cap.setCapability(色度选项、容量、选项);
WebDriver=新的ChromeDriver(des_cap);

解决方案没有帮助