Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
100 views
in Technique[技术] by (71.8m points)

c# - Why Firefox requires 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();

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

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.

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Addressing your questions one by one:

  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.

  2. 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.

  3. 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");
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...