-1

I use Selenium every 5 years or so and everytime it has changed beyond recognition. I just started a new Selenium project, googled some quickstart guides such as https://www.toolsqa.com/selenium-webdriver/run-selenium-test/ (written in September 2020) and https://www.guru99.com/first-webdriver-script.html (© 2020) and both seem to use WebDriver, e.g., by initiating their examples with WebDriver driver = new FirefoxDriver(); although the latter has a disclaimer saying that from Firefox 35 (I have 82) and up you should use Geckodriver.

I use Selenium for Java 3.141.59 downloaded from https://www.selenium.dev/downloads/ but it only has two references to Geckodriver (at least that is all that is displayed when it enter Ge and autocomplete in my IDE), GeckoDriverInfo and GeckoDriverService (as a comparison, there are nine references to WebDriver).

I have read the information here https://github.com/mozilla/geckodriver but it didn't make me any wiser, nor did https://en.wikipedia.org/wiki/Selenium_(software)#Selenium_WebDriver (Geckodriver isn't even mentioned on this Wikipedia page).

  1. What is the difference between Webdriver and Geckodriver?
  2. Why, if one download the newest/current version of everything, isn't Geckodriver included if that is the recommended tool since several (?) years?
  3. Why are guides that are written recently use Webdriver if Geckodriver is the way to go?

I think I have done a reasonably amount of research before asking this question but feel free to suggest improvements because I am genuinely confused.

d-b
  • 695
  • 3
  • 14
  • 43

2 Answers2

2

WebDriver is a specification. It defines the way how UI interfaces can be automated. GeckoDriver is the implementation of such specification - it is the WebDriver implementation for Firefox browser.

So basically a WebDriver is a server that exposes REST API to one side and that knows how to control browser on another side.

Here is short explanation of E2E flow (for Firefox and Java):

  1. You download Selenium java library. It provides Java client for interacting with web drivers
  2. You download GeckoDriver
  3. In your Java code you call WebDriver driver = new FirefoxDriver();
  4. Selenium library starts GeckoDriver executable in OS native manner
  5. In your Java code you call driver.get("http://my.url")
  6. Selenium library forms REST call to the server that is started with GeckoDriver. It invokes the endpoint according to this section of specification.
  7. GeckoDriver then translates this command to somewhat that Firefox understands so that the browser navigates to required page.

So basically you need 3 things to make everything work:

  • Selenium Java library that is basically a Java client for WebDriver REST API
  • GeckoDriver (that implements REST API according to WebDriver specification and translates it to commands which Firefox browse can understand)
  • Firefox browser
Alexey R.
  • 8,057
  • 2
  • 11
  • 27
1
  1. webdriver, is the parent of ChromeDriver ( from chrome ), GeckoDriver ( FireFox ), IEDriver and RemoteDriver. Possibly even more if they are supported. So, the GeckoDriver is used to control a FireFox Browser instance, but it implements the methods mentioned in the WebDriver interface.
  2. GeckoDriver is not included as it is specific to FireFox only, other users may want to use other browsers.
  3. To keep the flexibility of swapping out the implementations for different browsers. :)
tsamridh86
  • 1,480
  • 11
  • 23
  • So I need to download BOTH WebDriver from the link above and GeckoDriver? That leads to another question: I only downloaded WD and made a quick script that had no problem launching a new window in Firefox. How come? – d-b Nov 03 '20 at 11:18
  • WebDriver is typically present inside the selenium module already ( atleast in python and java ) and you would only need to download the GeckoDriver. Can you show me what you have downloaded and your code? – tsamridh86 Nov 03 '20 at 11:19