Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在Firefox上打开默认配置文件_Java_Firefox_Selenium_Selenium Webdriver - Fatal编程技术网

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

Java 无法在Firefox上打开默认配置文件,java,firefox,selenium,selenium-webdriver,Java,Firefox,Selenium,Selenium Webdriver,我正在尝试使用以下java代码设置firefox默认配置文件: ProfilesIni profile = new ProfilesIni(); FirefoxProfile ffprofile = profile.getProfile("default"); WebDriver driver = new FirefoxDriver(ffprofile); 这对我没用,有什么想法吗?为什么 我需要使用selenium webdriver打开相同的配置文件,因为我需要使用从另一个浏览器会话保存的

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

ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("default");
WebDriver driver = new FirefoxDriver(ffprofile);
这对我没用,有什么想法吗?为什么


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

为此,您需要创建新的firefox配置文件。 为此,请按照以下提到的步骤进行操作:-

  • 关闭firefox的所有浏览器会话
  • ctrl+R并输入“firefox.exe-p”
  • 您将看到创建配置文件向导并单击“创建配置文件”
  • 单击next并添加名称,如“profile1”,然后完成它
  • 现在,“Profile1也将在profiles中列出”
  • 双击“profile1”,打开您的URL并提供凭据。别忘了点击“记住密码”
  • Mozilla配置文件存储在“C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles\xyz.profile1”中
  • 现在,将代码编写为:-

    FirefoxProfile profile1=新的FirefoxProfile(新文件(“C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles\xyz.profile1”); WebDriver driver1=新的FirefoxDriver(profile1)

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

    我认为不可能使用保存在不同会话中的凭据引发什么异常?即使您打开了配置文件,它也不会记住登录凭据。Selenium为每个会话清除缓存。也许你可以从页面获取cred并将其存储在本地,然后在下一个会话中访问数据存储以使用它们。。。你能更详细地解释一下你到底想完成什么吗?可能有更好的解决方案。我找到了另一种方法来解决我的特定问题,但我将尝试您的想法,在本地存储Credentail,然后在另一个会话中加载。谢谢!我明天就试试。谢谢!当然如果需要进一步的信息,请尝试一下并让我知道。谢谢你,阿尼尔