gpt4 book ai didi

java - 无法在 Firefox 上打开默认配置文件

转载 作者:行者123 更新时间:2023-12-01 12:28:07 28 4
gpt4 key购买 nike

我正在尝试使用以下java代码设置firefox默认配置文件:

ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("default");
WebDriver driver = new FirefoxDriver(ffprofile);

这对我不起作用,知道为什么吗?

我需要使用 selenium webdriver 打开相同的配置文件,因为我需要使用从另一个浏览器 session 保存的登录详细信息打开浏览器。如果有人知道其他方法,请帮助我。

最佳答案

为此,您需要创建一个新的 Firefox 配置文件。为此,请按照以下步骤操作:-

  1. 关闭所有 Firefox 浏览器 session 。
  2. ctrl+R 并输入“firefox.exe -p”
  3. 您将看到创建个人资料向导并点击“创建个人资料”。
  4. 单击“下一步”并添加名称(例如“profile1”)并完成。
  5. 现在,“个人资料 1 也将在个人资料中列出”
  6. 双击“profile1”,打开您的 URL 并提供凭据。不要忘记点击“记住密码”
  7. Mozilla 配置文件存储在“C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles\xyz.profile1”。
  8. 现在,将代码编写为:-

    FirefoxProfile profile1= new FirefoxProfile(new File("C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles\xyz.profile1"));WebDriver driver1= new FirefoxDriver(profile1);

注意:- xyz 是字母数字值,可能会有所不同。也请注意这一点UserName 是您系统的用户名

关于java - 无法在 Firefox 上打开默认配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26177864/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com