Mat*_*cic 9 selenium google-chrome selenium-webdriver chrome-web-driver
我正在使用Chrome Web Driver 2.10 chromedriver_win32.zip和Selenium WebDriver 2.31.2.
启用详细日志记录后,似乎DesiredCapabilities(https://sites.google.com/a/chromium.org/chromedriver/capabilities)正常通过,
[1.174][FINE]: Initializing session with capabilities {
"browserName": "chrome",
"chrome.switches": [ ],
"chromeOptions": {
"args": [ ],
"binary": "",
"extensions": [ ],
"prefs": {
"download.default_directory": "C:\\Downloads",
"download.directory_upgrade": "true",
"download.extensions_to_open": "",
"download.prompt_for_download": "false"
}
},
"javascriptEnabled": true,
"platform": "WINDOWS",
"version": ""
}
Run Code Online (Sandbox Code Playgroud)
但Chrome网络驱动程序正在播放*.mp4而不是下载.
我已经尝试过如何使用Selenium Webdriver .NET绑定设置Chrome首选项的解决方案?但它似乎不适用于较新的Chrome Web驱动程序版本,如果我尝试使用selenium-dotnet-2.31.2与chromedriver_win_26.0.1383.0,它会崩溃.
有人有建议吗?
小智 7
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("download.default_directory", getClass().getResource("/data/input").toString().replace("%20", " ").replace("file:","").replaceFirst("/", ""));
options.setExperimentalOption("prefs", prefs);
options.addArguments("--test-type");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27453 次 |
| 最近记录: |