java - Remote webdriver - 使用 Rest Client Extension(附加组件)传递 firefox 配置文件

标签 java remotewebdriver selenium-grid2

目前我可以通过 RemoteWebDriver 发送 firefox 配置文件,但我无法通过配置文件发送 RestCLient 扩展。 我需要某个 REST 客户端扩展(firefox 附加组件)可用于我的测试用例执行。

如果我使用 firefox 驱动程序在本地运行测试用例,它就可以工作....但是我如何使用 RemoteWebDriver 实现相同的目的?

 File profileDirectory = new File("c://mach//lib//prof");
 FirefoxProfile profile = new FirefoxProfile(profileDirectory);
 driver = new FirefoxDriver(profile);
 driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

干杯

最佳答案

创建 FirefoxProfile 之后例如,使用 DesiredCapabilities 传输配置文件API (FirefoxDriver.PROFILE = "firefox_profile" ):

File profileDirectory = new File("c://mach//lib//prof");
FirefoxProfile profile = new FirefoxProfile(profileDirectory);

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);

注意:您不必提前创建配置文件,FirefoxProfile API 提供了几种方便的方法(“Method Summary”部分)来创建配置文件。例如,如果你想启动预装扩展的 Firefox,请使用:

FirefoxProfile firefoxProfile = new FirefoxProfile();
File extension = new File("extension.xpi");
firefoxProfile.addExtension(extension);

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);

使用远程网络驱动程序的文档:

关于java - Remote webdriver - 使用 Rest Client Extension(附加组件)传递 firefox 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16616808/

相关文章:

java - 如何自动构建混合的 Scala\Java Eclipse 工作区?

java - 在 Java 中扫描文本文件时使用对象

java.lang.NullPointerException Selenium 2 类

selenium - 创建 RemoteWebDriver 时传递的 Url/Ip

java - 在节点机器上执行批处理文件 - Selenium Grid

java - Selenium Grid2 中的 sendkeys() 函数速度很慢

java - 从毫秒返回 1970 年 1 月日期时损失了一个小时

java - Java 强制您提供无参数构造函数背后的逻辑是什么?

Python - 安装了扩展的远程 Webdriver