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

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

问题描述

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

Just a simple question I had today:

我用以下代码创建了一个新的硒项目:

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环境变量的当前目录或
a目录中不存在。该驱动程序可以在 https://github.com/mozilla/geckodriver/releases

为什么只有Firefox才需要下载/配置该驱动程序?

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

推荐答案

一个一个地解决您的问题:

Addressing your questions one by one:


  1. 为什么Firefox需要GeckoDriver?-对于Mozila Firefox,直到47.x版,它都是旧版浏览器,我们不需要gecko驱动程序。从47.x版开始的Mozila Firefox附带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浏览器和/或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&要使用Selenium 3.4.0的MS Internet Explorer,您需要从此位置或Chrome驱动程序或IEDriverServer,并将其保存在您的计算机中。将您的Mozila Firefox或Google Chrome或MS Internet Explorer升级到最新的稳定版本。在 System.setProperty 时,在代码中使用geckodriver / chromedriver / iedriver的绝对路径,如下所示:

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天全站免登陆