Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there is no need of external firefox driver like IE and chrome in selenium2.0..?

I have two doubts kindly help me to solve these

1)Why there is no firefox driver [.exe] like IE and chrome for running selenium2.0..?

2)Why do we need to initialize the IE and chrome driver while working with IE and chrome in selenium2.0..?

Thanks Mahesh

like image 717
Shetty's Avatar asked Jan 11 '23 22:01

Shetty's


2 Answers

  1. The FirefoxDriver is special, it comes pre-bundled in the package:

https://code.google.com/p/selenium/wiki/FirefoxDriver

Firefox driver is included in the selenium-server-stanalone.jar available in the downloads. The driver comes in the form of an xpi (firefox extension) which is added to the firefox profile when you start a new instance of FirefoxDriver.

In a very similar way to how the Safari driver works:

https://code.google.com/p/selenium/wiki/SafariDriver

The SafariDriver is implemented as a Safari browser extension. The driver inverts the traditional client/server relationship and communicates with the WebDriver client using WebSockets.

It is just an extension that is created and used to communicate with Firefox, the other browsers & drivers simply don't follow the same implementation and thus, you are required to start drivers & executables for the others.

2) Similar to what I just said. The implementation is different.

The IEDriver uses very low-level Win32 API calls to do some of it's work, the FirefoxDriver or ChromeDriver doesn't need to do this:

https://code.google.com/p/selenium/wiki/InternetExplorerDriver

like image 170
Arran Avatar answered Jan 31 '23 18:01

Arran


1. Mozilla has created the geckodriver binary for use with Firefox v48 and later.

NOTE: If using Firefox v47 and earlier then the following can be ignored as it uses the native Firefox browser implementation.

  • Geckdriver - GitHub
  • Geckodriver Releases

In order for Selenium to hook into Firefox the Geckodriver Binary Path System Property must be set before instantiating the WebDriver.

webdriver.gecko.driver = path/to/geckodriver

The following is sets the property in Java.

System.setProperty("webdriver.gecko.driver","path/to/geckodriver"); WebDriver driver = new FirefoxDriver();

As of 2017-03 the latest Geckodriver must be used with Selenium v3.3 and later.

Selenium Java - Maven Repository

2. The reason for initalizing the InternetExplorerDriver and Chromedriver is that each have specific browser options.

  • InternetExplorerDriver - SeleniumHQ
  • Chromedriver - Chrome Options

Also, the other reason for a driver binary is that Selenium does not have native implementations of the browser events that are part of Internet Explorer, Chrome and Firefox (as of v48 and later).

The only proof of this that I can find is from How to Use GeckoDriver - ToolsQA (2016-09-28) that states the removal of native Firefox events from Selenium.

Gecko Driver is the link between your tests in Selenium and the Firefox browser.

GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers i.e. Mozilla Firefox in this case.

As Selenium 3 will not have any native implementation of FF, we have to direct all the driver commands through Gecko Driver.

A logical assumption is that Selenium never had native events for Internet Explorer or Chrome previously and that is why it has been required to use the specific driver binary for each browser type.

like image 40
JasonTolotta Avatar answered Jan 31 '23 18:01

JasonTolotta