2016-05-31 103 views
1

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

回答

1

您可以通过如下使用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

设置希望它会帮助你。