Selenium WebDriver Tutorial

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated May 9, 2025

Introduction to Selenium WebDriver:

Earlier in this series, we published tutorials that focused more on Selenium IDE and its various aspects. We introduced the tool and discussed its features. We also constructed a few scripts using Selenium IDE and Firebug. From there, we moved on to different types of web elements available and their locating strategies.

Now that we are well versed with Selenium IDE, let us move our learning curve towards creating more advanced automation scripts using Selenium WebDriver. WebDriver is one of the most compelling automation testing tools. Let us discuss it in detail.

Overview of Selenium WebDriver

Introduction To Selenium WebDriver

WebDriver is one of the most powerful and popular tools in the Selenium toolkit. WebDriver comes as an extended version of Selenium RC with superfluous advantages and addresses many of its limitations. WebDriver extends its support to many latest browsers and platforms, unlike Selenium IDE.

WebDriver also doesn’t require the Selenium server to be started before the execution of the test scripts, unlike Selenium RC.

Selenium RC in aggregation with WebDriver API is known as Selenium 2.0. Selenium was so developed to support dynamic web pages and Ajax calls. It also supports various drivers to exercise web-based mobile testing.

WebDriver Architecture

WebDriver is a web-based testing tool with a subtle difference from Selenium RC. Since the tool was built on the fundamental where an isolated client was created for each of the web browsers; no JavaScript Heavy lifting was required in our very first tutorial.

WebDriver directly calls the Web browser and executes the entire test script in this fashion. WebDriver uses the browser’s support and capabilities to automate.

entire test script

Unlike Selenium RC, Selenium WebDriver doesn’t essentially require Selenium Server to be started before launching the test script execution. The user can leverage the benefit and may or may not require Selenium Server if he/she desires to perform the test execution on the same machine where the browser is residing.

Exceptional Cases when Selenium Server is required with WebDriver:

  • When the user wishes to execute test scripts on the remote machine.
  • When the user wishes to execute test scripts on the HtmlUnit Driver.
  • When the user wishes to execute test scripts on multiple platforms.

WebDriver is a purely object-oriented framework that works on the OS layer. It utilizes the browser’s native compatibility to automation without using any peripheral entity. With the increasing demand, it has gained a large popularity, and user base and has become by far one of the most extensively used open-source automation testing tools.

Features of Selenium WebDriver

Browser Compatibility

Browser Compatibility

WebDriver supports a diverse range of web browsers and their versions. It supports all the conventional browsers besides some unique and rare browsers like HtmlUnit browser, unlike Selenium RC and Selenium IDE.

HtmlUnit Browser executes the test scripts analogous to other browsers except for the fact that it runs in the headless mode, i.e. GUI-less mode and the user won’t be able to view the test script execution. Said that the test script execution transpires in headless mode, thus the execution speed takes a roll and quickens the execution.

WebDriver also supports web-based mobile testing. Thus it provides AndroidDriver and IphoneDriver to back web-based mobile testing.

Note: WebDriver doesn’t readily support new browsers.

Language Support

Earlier in the sessions, we learned to create scripts using record and playback functionality. We also saw how to create them manually using Selenese commands. While creating such test scripts, we come across various constraints.

Some limitations imposed by Selenium IDE are:

  • Doesn’t support iterations and conditional statements
  • Doesn’t support loops
  • Doesn’t support error handling
  • Doesn’t support test script dependency

The above impediments can be troubleshot programmatically. WebDriver facilitates the user to choose between the different programming languages and build their test script in the designated language.

Selenium WebDriver-supported programming languages are:

  1. Java
  2. C#
  3. PHP
  4. Pearl
  5. Ruby
  6. Python

Thus, the user can pick any of the programming languages (provided the language is supported by WebDriver) based on his/her competency and can start building test scripts.

Speed

When compared to other tools of the Selenium suite, WebDriver turns out to be the fastest tool of all. The communication is not channelized via any external intervention; rather, the tool directly communicates with the browser same as that of any user. Thus, WebDriver takes advantage of the browser’s native compatibility towards automation.

Selenium webdriver tutorial 3

Other tools from the Selenium suite like Selenium RC don’t communicate directly with the web browser. Client libraries (test scripts are written in any programming language) communicate with the Selenium Remote Control Server and Remote Control communicates with a Selenium Core (JavaScript Program) which communicates with the web browser.

Hence, this sort of twisted communication results as a hindrance to execution speed.

Selenium webdriver tutorial 4

Drivers, Methods, and Classes

WebDriver offers a wide range of solutions to some potential challenges in Automation Testing. It helps us to deal with complex types of web elements like checkboxes, dropdowns, and alerts with the help of dynamic finders.

Drivers, Methods, and Classes

With the advent of the mobile era, WebDriver API has also matured and introduced some of the key technologies to enter this horizon. WebDriver enables the user to perform web-based mobile testing. It provides two of the essential drivers to perform web-based mobile testing.

  • AndriodDriver
  • IphoneDriver

Moreover, WebDriver API is fairly simple and easy. It doesn’t include repetitious commands. Selenium RC embodies many of the tautological commands.

Conclusion

In this tutorial, we tried to make you acquainted with Selenium WebDriver by outlining its architecture, features, and limitations.

Here are the cruxes of this article.

  • Selenium suite comprises 4 basic components; Selenium IDE, Selenium RC, WebDriver, and Selenium Grid.
  • With WebDriver, users can automate testing for web-based applications. WebDriver is a different tool altogether that has various advantages over Selenium RC.
  • WebDriver supports a wide range of web browsers, programming languages and test environments.
  • WebDriver directly communicates with the web browser and uses its native compatibility to automate.
  • WebDriver’s support isn’t only limited to the periphery of traditional user actions. Instead, it supports efficient handling mechanisms for complex user actions like dealing with dropdowns, Ajax calls, switching between windows, navigation, handling alerts, etc.
  • The user can conduct web-based mobile testing with WebDriver. To support the same, WebDriver introduces AndroidDriver and iPhoneDriver.
  • WebDriver is faster than other tools of Selenium Suite because it makes direct calls to a browser without any external intervention.

Next Tutorial #9: In the next tutorial, we will discuss the installation procedure to get started with WebDriver initiating from scratch. We would also discuss the diverse range of drivers provided by WebDriver, each catering to different needs.

Till the time our next tutorial is under construction, the readers can visit Selenium’s official website. A detailed documentation concerning Selenium WebDriver is implemented on its official website.

If you have any specific requests/queries about this or any other tutorial in this Selenium online training series, let us know in the comments.

Was this helpful?

Thanks for your feedback!

Recommended Reading

  • Selenium on Chrome

    In-Depth Tutorial On ChromeDriver for Running Selenium Webdriver Tests on Chrome Browser: Handling browser alerts while automating through Selenium will be discussed in this article. Moreover, we will elaborate on the set up of the Selenium script for the Google Chrome browser along with appropriate examples and pseudo-codes. Upon going…

  • Selenium Webdriver in different browsers

    In this tutorial, we have explained how to set up Selenium WebDrivers for the various browsers available in the market: Selenium only supports web-based applications and to open them we need a browser. It is able to support various browsers for test automation. In the current industry, there are only…

  • selenium automation with phantomjs

    In This Article, Selenium Automation With PhantomJS is Explained With Code Examples: PhantomJS is a headless browser that is primarily used for GUI less automation. The performance and execution happening on this browser is faster and is generally used in the scenarios where manual monitoring is not required and on…

  • Selenium Tutorials

    A Complete List of the Best Selenium Tutorials to Learn and Master Selenium From Scratch:  After several frequent requests from STH readers, today we are finally launching our FREE Selenium Tutorial series. In this Selenium training series, we will cover all Selenium testing concepts and its packages with easy-to-understand practical…


READ MORE FROM THIS SERIES:



39 thoughts on “Selenium WebDriver Tutorial”

  1. @racsor

    I didn’t get your question completely but if you are trying to ask whether WebDriver works for IE9 and IE10 i.e. its compatibility with different browser versions.

    Yes, WebDriver works for multiple version of multiple browsers.

    Reply
  2. Can you please make these chapters ( selenium series )available for download as a document or PDF… so that we can take & study whenever we are offline. Reading over the internet makes bit uncomfortable.

    Reply
  3. I have checked tutorial on other sites also but Shruti has covered in so much detail that i feel this is the best.

    Thanks for writing that much detail about webdriver.

    Reply
  4. Hi Admin,
    As you mentioned that salenium consist selenium IDE ,Selenium RC,Selenium Web Driver and Selenium Grid ,so why you skipped the salenium RC section .You just started the salenium web driver after Salenium IDE.Is webriver merged with RC.Please resolve my quesries.
    Thanks

    Reply
  5. Thanks Shruti & team…good work…guys please try to reduce the frequency in between the two posts…eagerly waiting for next tuts…:-)

    Reply
  6. Guys I just want to say…In webdriver intro it should be mentioned that Webdriver is Interface which has various methods signature and they can be implemented by other classes like FirefoxDriver, chromeDriver etc…
    It is also an interview question.

    Reply
  7. Hi, i have some issues can anyone help me pls. I am trying to test an application which has login, search for flight and logout. Issues is Web Driver open the home page but can’t enter credentials while all command is correct. Can anyone please resolved the issues .
    Thanks in advanced.

    Reply
  8. Hi,

    In this series, could you please includes Page Object and Page Factory model with Selenium Webdriver. this topic always confuses me.

    thanks.

    Reply
  9. Thank you so much for sharing your knowledge. It will help us to solving problems related to automation testing using selenium web Driver.

    Reply
  10. Hi All,

    I want to explore API of particular tool(i.e., Splunk) through webdriver, Could anyone please help me out on this.

    Reply
  11. I am Fresher.Can I automate angularjs apps with selenium and also the projects of parature and CRM based application.Please help me.

    Reply
  12. Hi, can any body help me how to do unit testing on a website by using both seleniumIDE &Webdriver in com,mand prompt .

    Reply
  13. HI ..I have installed eclipse and configured Selenium webdriver with sample script but its not launching the URL which i am support to navigate instead it is opening a blank browser. Can you please help me on how resolve the issue. Thanks

    Reply
  14. Thank you for sharing your knowledge. I am a fresher to learn selenium testing from Seleniumlabs tutorial. but I found more knowledge from your post. Keep posting.

    Reply
  15. Thank’s for sharing your knowledge. It will help us to solving problems related to automation testing using selenium web Driver.

    Reply
  16. Please is there anyway, this tutorials can be done in video format? I am learn best when I see you do step by step approach in solving problems. I guess what am trying to say is that am a visual and audio learner. seeing is believing, it sticks better that way.

    Thanks in advance

    Reply
  17. @Swapnil

    Thank you for your kind words.
    We would surely try to the time span between two posts.

    Keep reading & keep learning..

    Reply

Leave a Comment