java - Selenium 远程 Web 驱动程序未从给定的 Firefox 配置文件开始
问题描述
测试用例
我想在 Firefox 远程 Web 驱动程序中安装自定义扩展。为此,我创建了一个 FirefoxProfile 并通过 setExtension 添加了自定义扩展。问题是我刚刚创建的配置文件没有添加到 Driver 实例中。这是我使用的一段代码:
File firefoxExtension = new File("src\\main\\resources\\browser-extensions\\firefox-extension.xpi");
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(firefoxExtension);
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile);
capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS,options);
try {
return new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + "@"
+ environmentVariables.getProperty("browserstack.server") + "/wd/hub"), capabilities);
} catch (Exception e) {
System.out.println(e);
return null;
}
系统
远程平台:Windows 10
Firefox 版本:68
Selenium:3.141.59
Selenium Hub:浏览器堆栈
预期结果
- 浏览器打开
- 加载了扩展的配置文件
- 浏览器可以使用 RemoteWebDriver 进行交互
解决方案
推荐阅读
- python - sklearn.linear_model LinearRegression 模块的系数如何返回
- c# - 即使控制台应用程序退出,也保持线程活跃
- ios - 自动布局约束警告
- javascript - Javascript - IE 自动化 - 事件未定义错误
- regex - 后视和前瞻PRCE
- ios - 为什么当我在 iOS 上滑动时,Safari 会重新加载页面?
- python - 使用 pandas date_range 标记财政年度不适用于最近的日期
- jquery - 如何为引导轮播添加缩放效果
- python - Python 等价于 Ruby 的 chunk_while?
- php - 通过 .BAT 执行 PHP 文件