Selenium-9 || Understanding WebDriver API.

Selenium WebDriver is a powerful tool in selenium package. It helps to identify the component on a web browser, perform an action, comparing the result and generating the reports.

Before starting this chapter I would suggest please go through with Chapter 1 of Selenium section:

WebDriver API

Basically, API stands for Application Program Interface. These resources or programs used to interact between two different platforms. In this case, these two platforms are Java Program and Web Browsers. Below image is showing the same relationship or process for WebDriver API.

WebDriver Architecture
WebDriver API

WebDriver API is basically a client/server process. However, as this is only at a conceptual level, to avoid any confusion these terms have been replaced with “local” and “remote” end.

Local End

It is a user-facing API. Basically, In this, we have to just declare the command(s) which can be utilized in the actual Java programs during the coding phase.

For example, we all aware of the get() method under WebDriver class, which is used to launch the browser as mentioned below:

public get(String URL);

We could find a declaration of the above method in the file named “WebDriver.java” by locating path “selenium-java-2.40.0-srcs.jar\org\openqa\selenium“.

Please note that these files would be present under source zip folder like “selenium-java-2.40.0-srcs.jar

Remote End

These files contain the implementation of the user-interface APIs.

For example, Implementation of the above method get() would be defined in HtmlUnitDriver.java file. This file can be located at mentioned path selenium-java-2.40.0-srcs.jar\org\openqa\selenium\htmlunit.

You can find below method in HtmlUnitDriver.java file:

public void get(String url) {
    // Prevent the malformed url exception.
    if (WebClient.URL_ABOUT_BLANK.toString().equals(url)) {
      get(WebClient.URL_ABOUT_BLANK);
      return;
    }

    URL fullUrl;
    try {
      fullUrl = new URL(url);
    } catch (Exception e) {
      throw new WebDriverException(e);
    }

    get(fullUrl);
  }

As described above method all the remaining APIs written in the same way. All these files are together combined and converted into a jar file after compilation for further use.

We need to just import these jar files into our Java project. Also, the same way we could create other APIs.

For detailed information on WebDriver API, please refer below link:

https://www.w3.org/TR/2013/WD-webdriver-20130117/

Selenium Tutorials:

Window Handling: 

Test Frameworks: 

Related Links: 


1158total visits,17visits today

Leave a Reply

Your email address will not be published. Required fields are marked *