Skip to toolbar

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. The 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 the 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/

13965total visits,15visits today

Leave a Reply

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

Site Statistics

  • Users online: 0 
  • Visitors today : 7
  • Page views today : 8
  • Total visitors : 48,852
  • Total page view: 67,267

   YouTube ChannelQuora

            Ashok Kumar is working in an IT Company as a QA Consultant. He has started his career as a Test Trainee in manual testing in August 2010. Then he moves towards the automation testing after 4 years. He started learning JAVA and Selenium by self to get the knowledge of automation.

       While learning these tools and working on multiple projects, he found that sometimes people get stuck in live scenarios in their project and they have to do lots of RnD to get out of it. So he decided to start blogging only for such scenarios, where anyone facing any problem in their project, can ask any question or give a solution or you can say an alternate solution to achieve the goal successfully.

Later on, he observed that some people want to learn Java but they have few questions in their mind like how to start Java, whether we should go for the online or offline course. So he started writing tutorials on Java, Jira, Selenium, Excel etc.