有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java获取firefox配置文件的配置文件当配置文件计数超过3(包括默认值)时,我没有选择给定的配置文件

当我有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配置文件包括:配置文件1、配置文件2和配置文件3。当我运行使用“profile_2或default”启动的FF代码时。未使用传递的配置文件名称(配置文件1)

Am在Win 10上使用selenium sever standalone 2.53.0和FF 46.0,64位


共 (1) 个答案

  1. # 1 楼答案

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

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

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

    希望有帮助