如何使用Webdriver找到Firefox配置文件路径

3

我找不到Firefox个人资料的路径,我正在使用以下代码:

static String HubHost;

static String HubPort;
HubHost=java.net.InetAddress.getLocalHost().getCanonicalHostName().toString().trim();

HubPort = "4444";

FirefoxProfile profile = new FirefoxProfile();

DesiredCapabilities dc = DesiredCapabilities.firefox();

profile.setAssumeUntrustedCertificateIssuer(false);

dc.setCapability(FirefoxDriver.PROFILE, profile);

System.out.println("Profile name:"+profile.layoutOnDisk().);

URL grid_url=new URL("http://"+HubHost+":"+HubPort+"/wd/hub");

webdriver = new CustomRemoteWebDriver(grid_url,dc);

String suggestedProfile = System.getProperty("webdriver.firefox.profile");

System.out.println("Profile name:"+ suggestedProfile);

在TEMP文件夹中生成了一个名为"anonymous651976431316177878webdriver-profile"的新配置文件,但无法通过代码获取此名称。

任何帮助都将不胜感激。


1
你为什么想知道新配置文件的临时路径呢?因为它会在WebDriver会话完成后被删除。 - bbbco
我想更改CERT8.db文件中的数据,该文件将处理浏览器SSL证书和Cookie。 - user2477308
你在处理SSL证书和Cookies方面有什么问题吗?WebDriver已经在浏览器的配置文件中集成了许多这些类型的场景,因此在初始化浏览器之前,我建议您首先检查一下:https://code.google.com/p/selenium/wiki/RubyBindings#SSL_Certificates - bbbco
1个回答

0
在尝试获取系统属性“webdriver.firefox.profile”之前,您应该对其进行设置。您能提供以下输出吗:
System.out.println("Profile name:"+ suggestedProfile);

如果您尚未设置该系统属性,则应打印以下内容:
Profile name:null

2
你好,当我打印以下代码时:System.out.println("Profile name:"+ suggestedProfile); 一个新的文件夹会在TEMP目录中创建,并以类似于“anonymous651976431316177878webdriver-profile”的名称打印在控制台中。 在我的情况下,我需要访问配置文件路径而不设置系统属性“webdriver.firefox.profile”。 我需要创建一个默认配置文件,而不设置配置文件路径,并需要访问该配置文件路径。谢谢 - user2477308

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接