Click here to Skip to main content
15,868,141 members
Articles / DevOps / Testing

Getting started with Selenium

Rate me:
Please Sign up or sign in to vote.
4.58/5 (9 votes)
13 Oct 2014CPOL6 min read 41.5K   19   10
Selenium to start with for automation Testing in a simple and diagramatic approach..

Introduction to SeleniumImage 1

Automated testing here means, using a software tool to run repeatable tests against the application to be tested. For example, when a site has 3 phases of registration to be tested for 1000 users. Entering so many records manually is not a bed of rose job. So, if it would have been possible to write scripts that would register for us 1000 users would sound great. Right!! There are many automation tools like TEST COMPLETE, WATIR, SELENIUM, etc. Here, we would be discussing about the Selenium. There are a lot of diagrams that I have mentioned in this article as diagrams explain the best.

Quote:

Selenium automates the browsers

Now, the above line is self-explanatory, that is we can understand here that Selenium is an automation tool that is used for automated testing the Web Browser. Selenium is an open source tool that is used both for function and regression testing for the web based applications, originally developed by "ThoughtWorks". It works with most of the browsers but mostly the following browsers:

                                                    Image 2

Languages Supported & O.S. supported

Along with this Selenium also works with multiple operating systems like:

  • Windows
  • Mac
  • Linux/UNIX, etc.

Selenium also supports multiple languages like:

  • Java
  • C#
  • Ruby
  • Pythn
  • Perl
  • Php

Mostly Java is the famous as it is platform independent. Another thing here worth to be noted is "It is not mandatory to write the Selenium scripts in the language in which the web application is written. It is not language specific. We can choose any of the language to write the Selenium scripts."

Tool Suites of Selenium

  1. Selenium IDE(Integrated Development Environment):
  •  Selenium IDE is an integrated development environment for Selenium tests.
  • Selenium IDE is a fire fox add-on that records clicks , typing and other actions to make test cases which tester can playback in the fire fox browser and export to Selenium RC.
  • Selenium IDE has the following features: record/ playback feature, debugging with step by step and break points.
  • Selenium IDE allows you to save tests as HTML, Java, Ruby scripts, or any other format. Allows you to add selenese commands as and when required.

2. Selenium RC(Remote Control):

  • A solution to cross browser testing.
  • A server, written in Java and so available on all the platforms.
  • Acts as a proxy for web requests from them.
  • Client libraries for many popular languages.
  • Bundles Selenium Core and automatically loads into the browser.
  • Selenium RC is used to enhance your script.

3. Selenium Grid:

  • Selenium-Grid allows the Selenium-RC solution to scale for test suites or test suites to be run in multiple environments.
  • With Selenium-Grid multiple instances of Selenium-RC are running on various operating system and browser configurations, each of these when launching register with a hub. When tests are sent to the hub they are then redirected to an available Selenium-RC, which will launch the browser and run the test.
  • This allows for running tests in parallel, with the entire test suite theoretically taking only as long to run as the longest individual test.

4.Selenium Web Driver:

  • WebDriver is designed in a simpler and more concise programming interface along with addressing some limitations in the Selenium-RC API.
  • WebDriver is a compact Object Oriented API when compared to Selenium1.0.
  • It drives the browser much more effectively and overcomes the limitations of Selenium 1.x which affected our functional test coverage, like the file upload or download, pop-ups and dialogs barrier

Installation

Steps to configure Selenium Web driver:

  1. Step 1: Download and Install Java (JDK-Java Development Kit) into your system
  2. Step 2: Download Eclipse into your system. From the downloaded Eclipse folder click the "eclipse.exe".
  3. Step 3Download the language specific client drivers. Selenium Client and WebDriver Bindings From here download the Java client version, click on the version mentioned to directly download from here- "2.43.1". A zip file will be downloaded, thus Extract all the files and then we find that there are: "libs" folder, 2 jar files and Change Log.
  4. Step 4: Now, we need to configure Eclipse  to integrate with the web driver. For that, Double click on the "eclipse.exe". Select a workspace folder,that is create a folder in any of the drive and select that.Image 3
  5. Step 5: Now we create a new java project..."File -> New -> Java Project" or "ctrl+N" -> Select on Java Project -> Next -> Give a Project name-> Click Finish.Image 4

Image 5Image 6    

 Then after creating the project there will be the project structure on the left panel as on the above image.

6. Step 6 : Now create a Package.For package creation, right click on the SRC of Test_Project-> New ->Package and name that package as – package_1. By convention, package names usually start with a lowercase letter. Under one project, more than one package can be created.    Image 7

Image 8

7.  Now create a Java Class.For Class creation, right click on the Package i.e " package_1" -> New ->Class and name that class as "class_1". By convention, Class names usually start with an uppercase letter. Under one package, more than one class can be created. Image 9 Image 10

8.  Now Configure the JAR files that have been downloaded in Step 3.For adding the JAR files into the project ["Test_Project"],click project 'Test_Project' -> Properties -> Select Java Build Path-> Libraries Tab ->Click On Add External Libraries button .

Image 11

Image 12

OR

Click on ‘Test_Project’ -> Build Path -> Configure Build Path ->  Select Java Build Path present on the left column -> Libraries Tab  -> Click On Add External Libraries button.

Image 13

Image 14

9.  Now select two JAR files present in the folder "selenium-2.43.1 ".  Select two JAR files present in the folder”selenium-2.43.1 “. Now click on Open.

Image 15

 

10. Then again click on the External Jars. Open the Libs folder and select all the JAR files present there and click on OK. 

Image 16

11. Now all the Required jar files  are added under the Libraries Tab. Now then click on OK.

Image 17

12. Now all the Jar files are added under the JRE system Libraries. Below is the view of the structure:

Image 18

Conclusion

In this article, I have covered the Installation and basics of automation testing using Selenium. Selenium is one of the most commonly used tool for automation testing. In the upcoming articles, I will be covering up with the script codes and practical usage of Selenium. Hope beginners in testing would get to learn basics of Automation testing in selenium from this. Any queries and suggestions are most welcome. :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Tester / Quality Assurance
India India
I am Sipra Ray, ISTQB certified - Quality Analyst at Mindfire Solutions.
An extrovert by nature ,I like to interact with people and share with all what I learn.
I would love to share and answer queries and gain knowledge from forums like Code Project
Follow up with my blogs at:- siprabugtracker.wordpress.com

Comments and Discussions

 
QuestionMessage Closed Pin
20-Jan-21 19:59
Locker Seo20-Jan-21 19:59 
AnswerMessage Closed Pin
20-Jan-21 19:53
Tech seo20-Jan-21 19:53 
QuestionMessage Closed Pin
8-Sep-20 5:11
PURUSOTTAM NATH8-Sep-20 5:11 
QuestionSelenium WebDriver Tutorials Pin
Naira kapoor3-Jan-17 6:22
Naira kapoor3-Jan-17 6:22 
QuestionRight click in Selenium Builder Pin
Member 1156964831-Mar-15 1:00
Member 1156964831-Mar-15 1:00 
QuestionThank you Pin
thileep201028-Feb-15 7:19
thileep201028-Feb-15 7:19 
AnswerRe: Thank you Pin
Sipra Ray10-Mar-15 19:33
Sipra Ray10-Mar-15 19:33 
GeneralThank You...Keep Up The Good Work! Pin
Member 1134291229-Dec-14 22:14
Member 1134291229-Dec-14 22:14 
QuestionHi Pin
Nimesh Lakhani11-Nov-14 23:01
Nimesh Lakhani11-Nov-14 23:01 
Questionnice and crisp Pin
Priyank Sharma7-Nov-14 18:09
Priyank Sharma7-Nov-14 18:09 
AnswerRe: nice and crisp Pin
Sipra Ray9-Nov-14 21:17
Sipra Ray9-Nov-14 21:17 
QuestionReally Nice Pin
Suraj Sahoo | Coding Passion13-Oct-14 22:59
professionalSuraj Sahoo | Coding Passion13-Oct-14 22:59 
AnswerRe: Really Nice Pin
Sipra Ray14-Oct-14 2:21
Sipra Ray14-Oct-14 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.