String exePath = "src\\Drivers\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", exePath);
String downloadFilepath = "U:\\Data\\Download";
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
options.merge(cap);
driver = new ChromeDriver(options);
selenium 更改Chrome浏览器保存文件路径
最新推荐文章于 2023-11-27 19:23:00 发布