chromedriver, how to use predefind settings
Each time chromedriver opens a browser, it creates new profile. The profile overwrites all the chrome settings. "Continue where you left off" option is part of the profile.
private static WebDriver startChrome() {
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=c:\\temp\\chromeProf"); // Set non-default profile
Map<String, Object> prefs = new HashMap<>();
prefs.put("session.restore_on_startup", 1); // Edit profile preferences to be "Continue where you left off"
options.setExperimentalOption("prefs", prefs); // Set preferences to ChromeOptions
WebDriver driver = new ChromeDriver(options); // Start driver with those options
driver.manage().window().maximize();
return driver;
}
本文介绍如何使用Chromedriver启动Chrome浏览器时设置特定配置文件,以实现从上次位置继续的功能。通过设定非默认配置文件并调整浏览器偏好设置,可以确保每次打开浏览器时都能恢复到之前的状态。
2442

被折叠的 条评论
为什么被折叠?



