webdriver.firefox.marionette & 的区别webdriver.gecko.driver [英] Difference between webdriver.firefox.marionette & webdriver.gecko.driver

查看:34
本文介绍了webdriver.firefox.marionette & 的区别webdriver.gecko.driver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在学习 Selenium,遇到了一个问题.

I am now learning Selenium and have met a problem.

我知道 Selenium 在没有驱动程序的情况下默认支持旧的 Firefox 版本.对于最新版本的 Firefox,我们必须下载驱动程序并使用 System.setProperty 定义它.

I am aware that Selenium supported old Firefox version by default without a driver. And for recent versions of Firefox, we have to download the driver and define it using System.setProperty.

根据此链接,对于 Firefox 45 和 46,启动驱动程序代码可能如下所示:

According to this link, for Firefox 45 and 46, start driver code could look like this:

WebDriver driver = new FirefoxDriver();

我的 Firefox 版本是 45.5.1.,但上面的代码仍然无法工作.所以根据这个link,我添加了:

My Firefox is version 45.5.1., but above code still won't work. So according to this link, I have added:

System.setProperty("webdriver.firefox.marionette","C:\geckodriver.exe");

它奏效了.

然后我意识到我没有在我的电脑上安装 geckodriver.exe.为了看看它是怎么回事,我改成了下面的代码:

Then I realized that I haven't installed geckodriver.exe on my computer. To see how it goes, I have changed to the code below:

System.setProperty("webdriver.firefox.marionette","");

它仍然有效.

那么,我的第一个问题来了:发生了什么?我确信我的环境中不存在 geckodriver.exe.如果没有指定位置,那我为什么要设置属性?

So, here comes my first problem: What happened? I am sure that no geckodriver.exe exists in my environment. If no location has been pointed, then why should I have to set property?

另外,我见过这样的代码:

Also, I have seen code like:

System.setProperty("webdriver.gecko.driver", "/tools/marionette/wires.exe");

我的第二个问题是 webdriver.gecko.driverwebdriver.firefox.marionettewires.exegeckodriver.exe?

My second question is that what is the difference between webdriver.gecko.driver and webdriver.firefox.marionette or wires.exeand geckodriver.exe?

推荐答案

在版本 45(推送到版本 47)之前,用于自动化 Firefox 的驱动程序是每个客户端都包含的扩展.但是这个扩展被放弃了,可能是因为政策的变化现在要求所有扩展都由 Mozilla 签名.

Up to version 45 (pushed to version 47), the driver used to automate Firefox was an extension included with each client. But this extension was dropped, probably due to the change of policy which now requires all the extensions to be signed by Mozilla.

Marionette 是 Firefox 附带/包含的新驱动程序.这个驱动有自己的协议,不直接兼容 Selenium/WebDriver 协议.

Marionette is the new driver that is shipped/included with Firefox. This driver has it's own protocol which is not directly compatible with the Selenium/WebDriver protocol.

Gecko 驱动程序(以前称为电线)是一个实现 Selenium/WebDriver 协议的应用服务器.它会转换 Selenium 命令并将它们转发给 Marionette 驱动程序.

The Gecko driver (previously named wires) is an application server implementing the Selenium/WebDriver protocol. It translates the Selenium commands and forwards them to the Marionette driver.

对于 Java 客户端,默认行为是使用 Gecko 驱动程序,但可以覆盖使用旧扩展作为具有 webdriver.firefox.marionette 属性的驱动程序:

For the Java client, the default behavior is to use the Gecko driver, but it can be overridden to use the legacy extension as a driver with the webdriver.firefox.marionette property:

System.setProperty("webdriver.firefox.marionette", "false");

或通过 FirefoxOptions 使用 marionette 功能:

or with the marionette capability through FirefoxOptions :

FirefoxOptions options = new FirefoxOptions()
  .setLegacy(true);

WebDriver driver = new FirefoxDriver(options);
// or with a remote server
WebDriver driver = new RemoteWebDriver(remoteUrl, options.toDesiredCapabilities());

或直接使用DesiredCapabilities:

DesiredCapabilities capa = DesiredCapabilities.firefox();
capa.setCapability("marionette", false);

WebDriver driver = new FirefoxDriver(capa);
// or with a remote server
WebDriver driver = new RemoteWebDriver(remoteUrl, capa);

要定义 Gecko 驱动程序的位置,请将驱动程序放在 PATH 环境变量中的文件夹中,或在属性 webdriver.gecko.driver<中定义位置/代码>:

And to define the location of the Gecko driver, either place the driver in a folder present in the PATH environment variable, or define the location in the property webdriver.gecko.driver:

System.setProperty("webdriver.gecko.driver", "C:\geckodriver.exe");

或使用在命令行中分配的属性启动远程服务器:

or launch a remote server with the property assigned in the command line:

java -Dwebdriver.gecko.driver="C:\geckodriver.exe" -jar selenium-server-standalone-3.4.0.jar

这篇关于webdriver.firefox.marionette &amp; 的区别webdriver.gecko.driver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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