【问题标题】:Starting chromedriver with saved passwords enabled启用已保存密码的启动 chromedriver
【发布时间】:2016-05-31 11:33:35
【问题描述】:

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

【问题讨论】:

    标签: java google-chrome selenium webdriver selenium-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 处维护您的自定义浏览器设置

    希望对你有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-12-26
      • 2018-11-14
      • 1970-01-01
      • 1970-01-01
      • 2013-08-16
      • 2015-06-02
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      相关资源
      最近更新 更多