Hello Friends! in this post, we will study about Gecko and Geckodriver and also their association with Mozilla Firefox browser.
What is Gecko?
Gecko is an open-source web browser engine used in Firefox and other applications developed by Mozilla.
What is Geckodriver?
Geckodriver is a server that serves webdriver requests from Gecko-based web browsers like Firefox. Hence, the path to the Geckodriver is required to be added in the System path while working with the Firefox browser in Selenium Webdriver.
Now, the question arises why were we not required to add the Geckodriver in earlier versions of Selenium Webdriver(before Selenium 3.0). This is because before the Selenium 3.0 release, the WebDriver implementation of Firefox was developed by guys from Selenium Project only. But with Selenium 3.0 Mozilla provided its own WebDriver implementation which required GeckoDriver for serving webDriver requests. So, all the webDriver commands are now required to be served by the GeckoDriver server. Adding the geckodriver.exe in the system path allows running the driver commands via the GeckoDriver server.
Hence, we get the below exception while working with FirefoxDriver without setting the “webdriver.gecko.driver” property-
Exception in thread “main” java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
A simple resolution of the exception being setting the webdriver.gecko.driver property.
System.setProperty("webdriver.gecko.driver", pathToGeckoDriver + "\\geckodriver.exe"); WebDriver driver = new FirefoxDriver();
Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals. You can connect with him on LinkedIn.