栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

无法解析构造函数FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

无法解析构造函数FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)

在使用 Selenium v​​3.11.xGeckoDriver v0.20.0Firefox Quantum v59.0.2时
,可以使用不同的选项来调用新的/现有的 Firefox配置文件

如果您希望在每次执行 测试时 使用 新的 Firefox配置文件 ,则可以使用以下代码块: __

    System.setProperty("webdriver.gecko.driver", "C:\path\to\geckodriver.exe");    FirefoxOptions options = new FirefoxOptions();    options.setProfile(new FirefoxProfile());    WebDriver driver = new FirefoxDriver(options);    driver.get("https://www.google.com");

如果您正在寻找使用一个 现有 的Firefox配置文件 在您每次运行 测试执行 首先你必须创建一个 Firefox的配置文件
手动下面的说明
在Windows上创建新的Firefox配置文件

现在,您有两种方法可以调用已创建的 Firefox配置文件 ,如下所示:

  • 您可以使用 FirefoxOptions 类来调用现有的 Firefox配置文件, 并且可以使用以下代码块:
        System.setProperty("webdriver.gecko.driver", "C:\path\to\geckodriver.exe");    ProfilesIni profile = new ProfilesIni();    FirefoxProfile testprofile = profile.getProfile("debanjan");    FirefoxOptions opt = new FirefoxOptions();    opt.setProfile(testprofile);    WebDriver driver =  new FirefoxDriver(opt);    driver.get("https://www.google.com");
  • 您还可以使用 DesiredCapabilities 类设置现有的 Firefox配置文件 ,然后在 FirefoxOptions 实例中合并,并且可以使用以下代码块:
        System.setProperty("webdriver.gecko.driver", "C:\path\to\geckodriver.exe");    ProfilesIni profile = new ProfilesIni();    FirefoxProfile testprofile = profile.getProfile("debanjan");    DesiredCapabilities dc = DesiredCapabilities.firefox();    dc.setCapability(FirefoxDriver.PROFILE, testprofile);    FirefoxOptions opt = new FirefoxOptions();    opt.merge(dc);    WebDriver driver =  new FirefoxDriver(opt);    driver.get("https://www.google.com");


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/386013.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号