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

查看:270
本文介绍了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版,但上述代码仍然无法正常工作.因此,根据此链接,我添加了:

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.

牵线木偶是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驱动程序(以前称为wires)是实现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功能:

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&之间的区别webdriver.gecko.driver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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