Back to Blog Home

Getting Started With Selenium WebDriver

Ranvijay Kumar Bhaskar| Testing | 9 months, 1 week


What is Selenium: The Complete Guide

Selenium has become the de-facto standard for web automation testing and it’s demand is continuously growing? More than 25,000 companies word over are using Selenium for their various testing use cases and it commands a whooping 30% + market share among Software Testing Tools.


Sounds good right?


Let’s try to understand what makes selenium such a leader of the Software Testing industry. In this article, we will understand what is Selenium and its components and will also do a quick getting started tutorial to get your hands dirty.


Why Selenium?

Selenium is a portable cross-platform open source testing framework used for web application automation and supports multiple browsers including Chrome, Internet Explorer, Safari, Firefox, etc. Selenium offers user-friendly interface with rich library and it’s scripts/tests can be written in multiple languages including PHP, python, java, ruby and a lot more. Selenium also supports concurrent execution of multiple tests which shortens the execution time. It is open sourced under Apache 2.0 license. 


How Selenium Works?

There are multiple types of Selenium components (IDE, Web Driver, RC, Grid). In this article we are going to understand latest and most popular Selenium Web Driver. Let us understand working of Selenium Web driver and understand what makes it so powerful.


Selenium Web Driver is next generation of Selenium RC and offers many advantages over it’s predecessor. 


Selenium code is written in one of the out of box supported language and is sent to the browser driver (Eg, chrome driver, IE Driver, etc.) and then after executing the code, fetches back the result. One of the main advantage of Selenium Web Driver is that both driver and browser are built natively which makes the communication really fast. 


Web driver also removes the need for running a server to execute the tests as it spins up an instance of the browser directly and controls it. 


One really useful aspect of WebDriver is that it uses native functionality of the operating system to control the browser instead of javascript commands which helps to circumvent security issues or other compatibility bugs. 


It also overcomes the problem of Single Host Origin which was one of the major issues in Selenium RC.


Let’s See this in Action

So lets get things rolling with a quick getting started tutorial. So let’s start coding. In this tutorial we will use Selenium Java and execute it on Google chrome web browser to open and then open website. 



  • Java JDK installed
  • Eclipse IDE
  • Selenium Jar
  • Chrome Web Driver



Create First Project

Open eclipse, select default workspace and you should see eclipse welcome page.




Lets open a nice project with :

File ->New->Other


It will then open Project wizard, Select Java and click on next



Enter Project Name and click Finish



If you are working on eclipse for first time, you might get open-perspective pop-up, click on open-perspective. This basically opens java environment friendly eclipse.


You should now see window like this. 



Let’s now include Selenium Jars so that we can use Selenium library. For this, we will have to right click on Project ->Build Path -> Configure build path



Select Libraries tab and click on Add external jars button and migrate to Selenium jars.(Selenium jars can be downloaded from Selenium official site, link here, Extract and place it on your machine). In my case I have put this jar in my D drive selenium folder.




Make sure you select all the jars in the folder and sub folder.




Click on Apply and Close



You should see new referenced library in your project now, if you expand you will be able to see all the jars we imported.




That’s it, now we have everything to start our code, go ahead and create new java class.

Right click on src folder-> New-> Class



Let’s Name this Test Class and click on Finish



You should see java class, we can now start coding selenium script here. But before that, if you could remember, we need driver as well in order to communicate with the browser, So lets go ahead and download driver(I am using chrome driver here) and store it in project directory in Drivers Folder. Let’s do that.



Now, finally lets start scripting. Let’s implement google search using Selenium Java. You can find inline comments to understand the steps.

Selenium libraries imported



Actual code



Now press ctrl+F11 to execute. Make sure to save before running. And here we go, google search got automated.


That’s it. It was so easy, isn’t it? You can find official documentation for further in-depth learning @



Join 1000+ People Who Subscribe to Weekly Blog Updates

Back to Blog Home