目前我能够通过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提供了几个方便的方法("方法摘要";节)来组成概要文件。例如,如果您想启动预先安装了扩展的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);
使用远程web驱动程序的文档:
- RemoteWebDriver
- Grid2(原始答案)和Grid4(2021年更新)
RemoteWebDriver
Java API文档