远程webdriver - 使用Rest Client Extension(附加组件)传递firefox配置文件 [英] Remote webdriver - Passing firefox profile with Rest Client Extension (add-on)

查看:118
本文介绍了远程webdriver - 使用Rest Client Extension(附加组件)传递firefox配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



如果我在本地使用firefox运行测试用例驱动程序它的工作....但我如何使用RemoteWebDriver实现相同的事情?

 文件profileDirectory = new文件(c :// //马赫LIB //教授); 
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
driver = new FirefoxDriver(profile);
driver.manage()。timeouts()。implicitlyWait(15,TimeUnit.SECONDS);

干杯

解决方案

创建 FilefoxProfile 实例,使用 DesiredCapabilities API( FirefoxDriver.PROFILE = firefox_profile):



< pre class =lang-java prettyprint-override> 文件profileDirectory = new File(c:// mach // lib // prof);
FirefoxProfile profile = new FirefoxProfile(profileDirectory);

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

注意:您不必提前创建个人资料, FirefoxProfile API提供了几个方法撰写个人资料。例如,如果要启动预先安装了扩展程序的Firefox,请使用:

  FirefoxProfile firefoxProfile = new FirefoxProfile(); 
文件扩展名=新文件(extension.xpi);
firefoxProfile.addExtension(扩展名);

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

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




Currently I am able to send a firefox profile over a RemoteWebDriver, but I am not able to send the RestCLient extension over the profile. I require a certain REST client extension(firefox add-on) to be available for my test case execution.

If I run the test case locally using firefox driver it works....but how do I achieve the same thing using 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);

Cheers

解决方案

After creating a FilefoxProfile instance, transfer the profile using the 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);

Note: You don't have to create a profile in advance, the FirefoxProfile API offers several convenient methods to compose a profile. For instance, if you want to launch Firefox with an extension pre-installed, use:

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);

Documentation for working with the remote web driver:

这篇关于远程webdriver - 使用Rest Client Extension(附加组件)传递firefox配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆