【问题标题】:Get profile of firefox ProfilesIni not selecting given profiles when profile count more than 3 including default当配置文件计数超过 3(包括默认值)时,获取 Firefox ProfilesIni 的配置文件不选择给定的配置文件
【发布时间】:2016-05-01 21:03:45
【问题描述】:

当我有 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。

【问题讨论】:

    标签: java selenium selenium-webdriver selenium-firefoxdriver


    【解决方案1】:

    如果您想启动自定义 Firefox 配置文件。你就是这样做的。

    首先创建ProfilesIni 的对象,然后使用getProfile() 获得所需的firefox profile,然后将该特定配置文件传递给WebDriver 初始化。

    ProfilesIni profiles = new ProfilesIni();
    FirefoxProfile profile = profiles.getProfile("profile_1");
    WebDriver driver = new FirefoxDriver(profile);
    

    希望对你有帮助!

    【讨论】:

    • 我也是这样做的(指定我的 FF 配置文件目录的路径 - {FirefoxProfile firefoxprofile = new FirefoxProfile(new File(profilepath));})。但是它的行为方式是,FFprofile 对象第一次选择传递的配置文件值。下次运行,如果我更改“配置文件名称”并运行,FF 仅使用以前的配置文件启动,而不是当前运行配置文件名称。
    猜你喜欢
    • 2021-04-18
    • 2022-01-21
    • 2017-08-07
    • 2021-02-01
    • 1970-01-01
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 2012-11-14
    相关资源
    最近更新 更多