Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

A simple way to get started with Selenium

4.57/5 (5 votes)
15 Oct 2014CPOL5 min read 7.8K   1  
Introduction to Selenium Languages Supported & O.S. supported Tool Suites of Selenium Installation Introduction to Selenium         Automated testing here means, using a software tool to run repeatable tests against the application to be tested.

Introduction to Selenium         z9

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.

“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:

z13

Languages Supported & O.S. supported

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

  • Windows
  • Mac
  • Linux/UNIX

Selenium also supports multiple languages like:

  • Java
  • C#
  • Ruby
  • Python
  • 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. Download and Install Java (JDK-Java Development Kit) into your system
  2. Download Eclipse into your system. From the downloaded Eclipse folder click the “eclipse.exe“.
  3. Download 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. 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.1.1
  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.1

2

3

    

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

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 and click on Finish.

By convention, package names usually start with a lowercase letter. Under one project, more than one package can be created.

4.1

57.  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 and click on Finish.

By convention, Class names usually start with an uppercase letter. Under one package, more than one class can be created.

7

8

8.  Now Configure the JAR files that have been downloaded in Step 3. For adding the JAR files into the project, right click on project i.e   ‘Test_Project’ -> Properties -> Select Java Build Path present on the left column -> Libraries Tab  -> Click On Add External Libraries button.

9.1

10

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.

9

10
9.  Now go to the folder where you have extracted the JAR files. Select two JAR files present in the folder”selenium-2.43.1 “. Now click on Open.

11

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

12

11. Now all the required jar files are added under the Libraries Tab. Now click on Ok.

14

12. Now all the jar files are added under the JRE System libraries.Here is a view of the structure.

16

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)