如何使用RemoteWebDriver的扩展设置FirefoxProfile?

时间:2013-08-05 12:32:03

标签: webdriver selenium-webdriver selenium-firefoxdriver remotewebdriver

我需要在RemoteWebDriver上运行我的WebDriver测试,其中Firefox配置文件加载了扩展名。我目前的代码是

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities = DesiredCapabilities.firefox();
File firebug = new File("firebug.xpi");
File netexpert = new File("netexpert.xpi");
try {
    firefoxProfile.addExtension(firebug);
    firefoxProfile.addExtension(netexpert);
} catch (IOException e) {}
desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(<<serverurl here>>, getDesiredCapabilities());

我收到以下错误

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.32.0', revision: '6c40c187d01409a5dc3b7f8251859150c8af0bcb', time: '2013-04-09 10:39:28'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.5', java.version: '1.6.0_51'
Driver info: driver.version: RemoteWebDriver

当我没有设置Firefox配置文件并且测试运行正常时,我没有收到任何错误。

编辑:在删除netexpert.xpi时,测试运行正常。我的独立测试在FirefoxDriver(不是RemoteWebDriver)上正常运行,同时启用了netexpert。

1 个答案:

答案 0 :(得分:0)

我改变后的工作

RemoteWebDriver remoteWebDriver = new RemoteWebDriver(<<serverurl here>>, getDesiredCapabilities());

WebDriver webDriver = new RemoteWebDriver(<<serverurl here>>, getDesiredCapabilities());