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

Lea*_*pet 9 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);
Run Code Online (Sandbox Code Playgroud)

干杯

Rob*_*b W 21

创建FilefoxProfile实例后,使用DesiredCapabilitiesAPI(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);
Run Code Online (Sandbox Code Playgroud)

注意:您不必提前创建配置文件,FirefoxProfileAPI提供了几种方便的方法来组成配置文件.例如,如果要启动预先安装了扩展程序的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);
Run Code Online (Sandbox Code Playgroud)

使用远程Web驱动程序的文档: