A Simple Way to Get Started With Selenium

Contents

  • Introduction to Selenium
  • Languages Supported and 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. 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 roses. So, if it would have been possible to write scripts that would register 1000 users for us; that sounds great, right? There are many automation tools like TEST COMPLETE, WATIR, SELENIUM, and so on. Here, we will be discussing Selenium.
"Selenium automates the browsers"
Now, the preceding line is self-explanatory. That is, we can understand here that Selenium is an automation tool for automated testing of a web browser. Selenium is an open source tool for both function and regression testing for web-based applications, originally developed by "ThoughtWorks". It works with most of the browsers but mostly the following browsers:

Languages Supported and 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 most famous since it is platform-independent. Another thing here worth noting is "It is not necessary 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 languages to write Selenium scripts."

Tool Suites of Selenium

  1. Selenium Integrated Development Environment (IDE)

    • The Selenium IDE is an integrated development environment for Selenium tests.
    • The Selenium IDE is a Firefox add-on that records, clicks, types and does other actions to make test cases that the tester can playback in the Firefox browser and export to Selenium RC.
    • The Selenium IDE has the following features: record/ playback feature, debugging with step-by-step and breakpoints.
    • The 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 Remote Control (RC)

    • A solution to cross-browser testing.
    • A server, written in Java and therefore 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 systems and browser configurations. Each of these, when launching, register with a hub. When the tests are sent to the hub they are then redirected to an available Selenium-RC that will launch the browser and run the test.
    • This allows for the running of tests in parallel, with the entire test suite theoretically taking only as long to run as the longest individual test.

  4. Selenium Web Driver

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

Installation

The following is the procedure to configure the 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 "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 specified to directly download from "2.43.1". A Zip file will be downloaded, thus extract all the files and then we find that there is a "libs" folder, 2 JAR files and a Change Log.

  4. Now, we need to configure Eclipse to integrate with the web driver. For that, double-click on "eclipse.exe". Select a workspace folder; that is, create a folder in any drive and select that.



  5. Now we create a new Java project. "File -> New -> Java Project" or "Ctrl+N" then select the Java Project then click Next then provide a project name then click Finish.







    Then after creating the project the project structure wil be on the left panel as in the preceding image.

  6. Now create a Package. For package creation, right-click on the src of Test_Project then click New -> Package and name that package 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.





  7. Now create a Java Class. For class creation, right-click on the Package, "package_1" then select New -> Class and name that class 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.







  8. Now Configure the JAR files that have been downloaded in Step 3. For adding the JAR files into the project, right-click on the project, "Test_Project" then select Properties then select Java Build Path present on the left column then seelct the Libraries Tab then click on the Add External Libraries button.





    Or

    Click on "Test_Project" -> Build Path -> Configure Build Path then select Java Build Path present on the left column then seelct the Libraries Tab then click on the Add External Libraries button.





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



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



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



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

Conclusion

This article explained the installation and basics of automation testing using Selenium. Selenium is one of the most commonly-used tools for automation testing. In the future articles, I will be covering the script codes and practical usage of Selenium.

I hope beginners in testing will learn the basics of Automation testing in Selenium from this. Any queries and suggestions are most welcome.