当我有 3 个(随机创建的)自定义 FF 配置文件和 1 个默认配置文件时,下面的代码没有更改 FF 配置文件。
WebDriver driver;
String profilepath = "<user Dir>/Local/Mozilla/Firefox/Profiles/";
ProfilesIni profilesini = new ProfilesIni();
FirefoxProfile firefoxprofile = new FirefoxProfile(new File(profilepath));
firefoxprofile = profilesini.getProfile("profile_1");
driver = new FirefoxDriver(firefoxprofile);
FF 配置文件为:profile_1、profile_2 和 profile_3。当我运行使用“profile_2 或默认值”启动的代码 FF 时。不包含传递的配置文件名称 (profile_1)
我在 Win 10 64 位上使用 selenium-sever 独立版 2.53.0 和 FF 46.0。
最佳答案
如果您想启动自定义 Firefox 配置文件。这就是你的做法。
首先创建一个 ProfilesIni
对象,然后使用 getProfile()
获取所需的 firefox 配置文件
,然后将该特定配置文件传递给WebDriver
初始化。
ProfilesIni profiles = new ProfilesIni();
FirefoxProfile profile = profiles.getProfile("profile_1");
WebDriver driver = new FirefoxDriver(profile);
希望对你有帮助!
关于java - 获取 Firefox ProfilesIni 的配置文件,当配置文件计数超过 3(包括默认值)时不选择给定的配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36971914/