在启用保存密码的情况下启动 chromedriver

Starting chromedriver with saved passwords enabled

每次我使用 chromedriver 启动 Chrome 网络浏览器时,它都会在禁用任何自定义设置的情况下正常启动。我有一个案例,我登录了一个网站,我想访问该帐户以获取一些信息。但是,新打开的浏览器不再登录该帐户。即使我手动打开一个新的浏览器,我仍然在同一页面上登录。有没有办法启用自定义设置?最好在 Java。

您可以通过使用 ChromeOptions 实现此目的,如下所示:-

DesiredCapabilities capabilities = DesiredCapabilities.chrome();

String chromeDirPath = "provided here a path where you want to custom chrome dir which could be use everty time you launch"
//ensure chromeDirPath exist in dir

ChromeOptions options = new ChromeOptions();
options.addArguments("--user-data-dir="+chromeDirPath);

capabilities.setCapability(ChromeOptions.CAPABILITY, options);

WebDriver driver = new ChromeDriver(capabilities);
driver.get("url");

现在它将在 chromeDirPath

维护您的自定义浏览器设置

希望对您有所帮助。