为什么 Firefox 需要 GeckoDriver? [英] Why Firefox requires GeckoDriver?

查看:36
本文介绍了为什么 Firefox 需要 GeckoDriver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天有一个简单的问题:

Just a simple question I had today:

我用这个代码创建了一个新的 selenium 项目:

I created a new selenium project with this code:

FirefoxDriver driver = new FirefoxDriver();
//ChromeDriver driver = new ChromeDriver();
//InternetExplorerDriver driver = new InternetExplorerDriver();

Chrome 和 IE 开箱即用,但 Firefox 会抛出:

With Chrome and IE works out of the box, but with Firefox throws:

geckodriver.exe 文件不存在于当前目录或PATH 环境变量上的目录.司机可以在 https://github.com/mozilla/geckodriver/releases 下载.

The geckodriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at https://github.com/mozilla/geckodriver/releases.

为什么我们只需要为 Firefox 下载/配置这个驱动程序?

Why only for Firefox do we have to download/configure this driver?

推荐答案

一一解决您的问题:

  1. 为什么 Firefox 需要 GeckoDriver? - 对于 47.x 版之前的 Mozila Firefox,它是旧版浏览器,我们不需要 Gecko 驱动程序.Mozila Firefox 从 47.x 版本开始,它带有 Marionette,它是 Mozilla 的 Gecko 引擎的自动化驱动程序.它可以远程控制 Gecko 平台(例如 Firefox)的 UI 或内部 JavaScript.

  1. Why does Firefox require GeckoDriver? - For Mozila Firefox till version 47.x it was the legacy browser and we didn't need gecko driver. Mozila Firefox from version 47.x onwards it comes with Marionette, which is an automation driver for Mozilla's Gecko engine. It can remotely control either the UI or the internal JavaScript of a Gecko platform, such as Firefox.

Chrome 和 IE 开箱即用 - 理想情况下,Chrome 和 IE 都不应该工作.但是,由于您在安装/配置 Google Chrome 时有意/无意地在环境变量中添加了二进制文件的位置 &MS Internet Explorer 或其他相关软件,这些二进制文件很容易定位自动使用.

With Chrome and IE works out of the box - Ideally neither Chrome nor IE should have worked. But as you have added the location of the binaries in the Environment Variables knowingly/unknowingly while installation/configuration of Google Chrome & MS Internet Explorer or other dependent softwares, those binaries are easily located & used automatically.

为什么我们只需要为 Firefox 下载/配置这个驱动程序? - 它不仅适用于 Firefox,而且适用于 Google Chrome &MS Internet Explorer 要使用 Selenium 3.4.0,您需要从 此位置 或 Chrome 驱动程序或 IEDriverServer 并将其保存在您的机器中.将您的 Mozila Firefox 或 Google Chrome 或 MS Internet Explorer 升级到最新的稳定版本.在代码中使用 geckodriver/chromedriver/iedriver 的绝对路径,而 System.setProperty 如下:

Why only for Firefox do we have to download/configure this driver? - It is not only Firefox but also for Google Chrome & MS Internet Explorer to work with Selenium 3.4.0 you need to mandatory download gecko driver v0.16.0 (or above) from this location or Chrome driver or IEDriverServer and save it in your machine. Upgrade your Mozila Firefox or Google Chrome or MS Internet Explorer to the latest stable version. Use the absolute path of the geckodriver/chromedriver/iedriver in your code while System.setProperty as follows:

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

这篇关于为什么 Firefox 需要 GeckoDriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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