1

When we launch the web browser using selenium we have to set the system property.

I'd like to know what is the meaning of webdriver.ie.driver, webdriver.chrome.driver and where this keyvalue is located

I have set the path before initializing it

System.setProperty("webdriver.ie.driver", "C:\\driver\\IEDriverServer.exe");

WebDriver driver = new InternetExplorerDriver();

I just want to know the meaning of Webdriver.ie.driver?

NarendraR
  • 7,577
  • 10
  • 44
  • 82
Sai
  • 389
  • 6
  • 18
  • You can find your answer here: [What is Webdriver](https://stackoverflow.com/questions/54459701/what-is-selenium-and-what-is-webdriver/54482491#54482491) – Tài Hoàng Apr 01 '19 at 07:13

4 Answers4

3

Selenium code interacts with InternetExplorerDriver through JSON wire Protocol and then InterenteExplorerDriver will further communicate with Internet Explorer Browser. So basically, IE driver will act as a bridge between selenium code and IE Browser.

System.setProperty is located in your system class. setProperty is static string method where you can store your values based on key-value pair.

System.setProperty(“propertyName”, “value”)” is exactly what it says. That is, it sets the system property ‘propertyName' to have the value 'value'.

In Selenium, you use this method because the browser doesn’t have a built-in executable to run the automation code so you will need a Chrome/IE/Gecko(according to requirement) driver server for communicating your Selenium code to the browser.

In simple words, to set the path of the driver for the respective browser you will need the system.setProperty. For eg.

System.setProperty("webdriver.ie.driver", "Path of your Driver");

WebDriver driver = new InternetExplorerDriver();

driver.get("http://seleniumhq.com");

This will launch selenium official site in Internet Explorer using Internet Explorer driver where the initialisation of the driver is handled by system.setproperty method.

This has to be the first line of code needs to be executed in your selenium script before any test method to initialise the driver.

Dhru 'soni
  • 1,024
  • 7
  • 23
  • Hi Dhru'soni, Thank you so much for replying my question. I would like to know where the Keyvalue(webdriver.ie.driver) is locatated why we are having 2 dots in the Key webdriver.ie.driver – Sai Apr 01 '19 at 09:01
  • @Vijayakumarj you will get more information on this link. https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver – Dhru 'soni Apr 01 '19 at 09:16
2

why we use WebDriver driver = new FirefoxDriver() in script see below

Flow of webdriver

Following are the few points based on the above image.

-SearchContext is the super most interface in selenium, which is extended by another interface called WebDriver.

-All the abstract methods of SearchContext and WebDriver interfaces are implemented in RemoteWebDriver class.

-All the browser related classes such as FirefoxDriver, ChromeDriver etc., extends the RemoteWebdriver class.

What is WebDriver?

WebDriver is an interface provided by Selenium WebDriver. As we know that interfaces in Java are the collection of constants and abstract methods(methods without any implementation). The WebDriver interface serves as a contract that each browser specific implementation like ChromeDriver, FireFoxDriver must follow. The WebDriver interface declares methods like get(), navigate(), close(), sendKeys() etc. and the developers of the browser specific drivers implement these methods to get the stuff automated. Take for example the ChromeDriver, it is developed by the guys from Chromium team, the developers of the Selenium project don't have to worry about the implementation details of these drivers.

WebDriver driver = new FirefoxDriver();

Having a reference variable of type WebDriver allows us to assign the driver object to different browser specific drivers. Thus allowing multi-browser testing by assigning the driver object to any of the desired browser.

For more information check following links:-

WebDriver driver = new FirefoxDriver() – Why we write in Selenium Scripts

How does it work?

In Selenium , WebDriver is a interface.

FirefoxDriver is a class. It implements all the methods of WebDriver interface.

Pradnya Bolli
  • 1,915
  • 1
  • 19
  • 37
1

When we start the ie browser for selenium automation in java we write the following lines of code

System.setProperty("webdriver.ie.driver", "C:\\driver\\IEDriverServer.exe");

WebDriver driver = new InternetExplorerDriver();

Let us now see this is more detail:

  1. System.setProperty(): As already discussed in the link system.setProperty(). System in java has a static member variable known as props which is of type Properties. It is a hash table which consists of key value pairs.

When java starts a program. JVM instance is started which has its own System.propties() hash table.

When we write

System.setProperty("webdriver.ie.driver", "C:\\driver\\IEDriverServer.exe");

we are creating a key value pair who's key is webdriver.ie.driver and value is its path.

  1. new InternetExplorerDriver();:

according to the selenium java code for chrome driver

chrome driver

Default constructor accepts services parameter.These services is the path of the browser driver we are initiating

enter image description here

Sarthak Gupta
  • 392
  • 1
  • 10
0

ChromeDriver is a separate executable that WebDriver uses to control Chrome. It is maintained by the Chromium team with help from WebDriver contributors. If you are unfamiliar with WebDriver, : Follow these steps to setup your tests for running with ChromeDriver:

Ensure Chromium/Google Chrome is installed in a recognized location ChromeDriver expects you to have Chrome installed in the default location for your platform. You can also force ChromeDriver to use a custom location by setting a special capability. Download the ChromeDriver binary for your platform under the downloads section of this site Help WebDriver find the downloaded ChromeDriver executable Any of these steps should do the trick: include the ChromeDriver location in your PATH environment variable (Java only) specify its location via the webdriver.chrome.driver system property (see sample below) (Python only) include the path to ChromeDriver when instantiating webdriver.Chrome (see sample below) http://chromedriver.chromium.org/getting-started

Below is the reference with in selenium package, where the value will be used.

/**
* System property that defines the location of the chromedriver executable that will be used by
* the {@link #createDefaultService() default service}.
*/
public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";
supputuri
  • 13,644
  • 2
  • 21
  • 39