Selenium-Software-Testing

Know About Selenium Software Testing Tools

Selenium Software Introduction

Selenium is a cluster of independent tools, and is not just a simple tool.

The latest industrial trends have shown a mass movement towards automation testing. So, a demand to bring in the practice of automating manual scenarios has been raised.

In this Blog you will learn about the Selenium software testing tools and steps.

Benefits of Implementing Selenium Software Testing Tools

  • Repeated Test Cases Execution

  • A large test matrix testing

  • Caters Parallel Execution

  • Hastens Unattended Execution

  • Reduces human generated errors thereby improves accuracy

  • Time and money saving

Finally Resulted In

  • Higher Return on Investment (ROI)

  • Quicker GoTo market

There are many benefits of automation testing, understood well and mostly talked about in the software test industry.

Selenium is a single best and easily adaptable solution for Automating web based applications testing due to its-:

  • Open source
  • A large user base and helping communities
  • Multi platform and browser compatibility
  • Active repository developments
  • Multiple language implementations support

Selenium supports a broad range of browsers, technologies and platforms.

Components of Selenium

Selenium is referred as a ‘Suite Package’ having several testing tools. Every tool is designed to offer various testings and test environment requirements.

Selenium Suite Package have following sets of tools

  • Selenium Integrated Development Environment (IDE) – As a plugin to firefox records, plays and also export tests in different languages. Based on ‘fit html’, ‘html test case’ is the most appealing format.
  • Selenium Remote Control (RC) Also Referred as ‘Selenium 1’ – It helps to play exported test in different OS/platform.
  • Selenium Grid – A number of selenium machines can be controlled with it. Also, it is typically not only needed for load test, so you may ignore it.
  • Selenium WebDriver – It is the latest version of the Selenium. Supports multiple languages, the Android Testing & iPhone testing as well.

In a combination Selenium RC and WebDriver, are known as Selenium 2.

As stated Above, Selenium RC alone is also referred as Selenium 1.

Know About Selenium tools

SeleniumCore

An engineer named Jason Huggins at Thought Works is having the credit to develop Selenium with his continuous efforts. While he was working on the testing of an internal Time and Expenses application, he realized the need to get rid of repetitive manual tasks for an automation testing tool without compromising with the accuracy and quality.

In early 2004, a JavaScript program named “JavaScriptTestRunner” is developed, much similar to that of a user communicating with the browser and that could automatically control the browser’s actions.

So, this tool was presented before large audience and eventually categorized in the open source category having its potential to grow as a re-usable testing framework for other web applications, later on this tool acclaimed as “Selenium Core”.

Selenium IDE

The Selenium-IDE (Integrated Development Environment) is an easy to use Plugin for firefox and one of the most popular automated testing tool amongst the testing professionals to record and playback tests i.e. QTP, WinRunner to develop test cases for Selenium.

The recorded test can be then exported in various languages e.g. html, Java , .net , perl , ruby etc. Moreover, using “selenium remote control”, exported test can be run in any platform and browser.

Also, Selenium-IDE contains a context menu which helps to select an UI element from the currently displayed page of browser.

You have required to do recording in main firefox window (As shown in Screen shot).
Type any additional missed (e.g. timeout) command using Selenium IDE.

Options can be Opened to change default timeout or to add user extension to extend selenium.

Selenium RC (Selenium Remote Control)

Selenium RC originate as a result to overcome various problems incurred by Selenium IDE or Core. It is written in java that helps a user to develop test scripts for a web based application in a programming language of user’s choice.

While using Selenium Core, various restrictions and loopholes made the testing process a cumbersome and a far reaching task for the user to leverage the complete benefits of the tool.

For Example, While launching the JavaScript Program from “http://www.seleniumhq.org/”, the pages will be accessed within the same domain such as “http://www.seleniumhq.org/projects/” or “http://www.seleniumhq.org/download/”. But the other domains like google.com, yahoo.com would no longer be accessible.

Thus, to overcome the problem of same origin policy, user has to install the entire application on the Selenium Core as well as web server.

Thus, Selenium RC came into existence, in order to govern the same original policy without the need of making a separate copy of application under test on the Selenium Core.

Selenium RC supports a wide range of browsers and platforms, Unlike selenium IDE.

Description for Workflow
  • In a desired programming language, user creates test scripts.

  • There is a designated client library, for every programming language.

  • The test commands are deported to the selenium server by the Client library.

  • The test commands are converted and deciphered into JavaScript commands by Selenium server and it sends them to the browser.

  • Using selenium core, browser executes the commands and results are sent back to the selenium server.

  • Finally the test results delivered to the client library by selenium server.
Before creating Selenium RC scripts, a few pre-requisites are there to be in place 
  • An Integrated Development Environment –Eclipse or Netbeans etc.

  • A Programming Language – Java, C#, Python etc.

  • A Framework for Testing (optional) – JUnit, TestNG etc.

  • And off course a Selenium RC setup.

Selenium Grid 

The emerging trends on multiple platforms and browsers concurrently demand to execute same or different test scripts. In order to address the need for executing the test suites simultaneously on multiple platforms, Pat Lightbody introduced Selenium Grid. So, a tester’s life has become positive and favorable with the Selenium Grid to achieve distributed test execution, testing under different environments and remarkably saving execution time.

SeleniumWebDriver 

In the year 2006, another engineer named as Simon Stewart created Selenium WebDriver at ThoughtWorks. Having a subtle difference with Selenium RC, WebDriver is also a web testing tool. No Heavy lifting of JavaScript was required as it was built on the fundamental where an isolated client was created for each of the web browser. A more powerful automated testing tool was developed named as Selenium 2, with a compatibility analysis between Selenium RC and WebDriver.

WebDriver is purely object oriented and clean framework. Without using any peripheral entity, it utilizes the browser’s native compatibility to automation.It has gained a large user base and popularity with the increasing demand.

Selenium 2

WebDriver is clean and a purely object oriented framework. It utilizes the browser’s native compatibility to automation without using any peripheral entity. Webdriver merging with Selenium(2.0) allows Selenium tests to easily run even without browser (and suitable for load test). Selenium 2 does not faces the javascript limitations due to usage of native plugin to browser to run its tests. With the increasing demand it has gained a large popularity and user base.

Selenium 3 

An advanced version of Selenium 2 is referred as Selenium 3. It is a mobile and web applications focused tool for automation. With the extension of WebDriver API, Selenium 3 supports the mobile testing needs. Much expected that this tool will be launched soon in the market.

Key differences between Selenium IDE, RC & WebDriver

Selenium IDE

Selenium RC

Selenium WebDriver

Works only in Mozilla browser. Works on all browsers like Firefox, Chrome, IE, Safari, Opera etc. Works on all browsers like Firefox, Chrome, IE, Safari, Opera etc.
Record and playback support Record and playback support Record and playback support
No need to start server before executing the test script. Needed to to start server before executing the test script. No need to start server before executing the test script.
A GUI Plug-in A stand alone java program, helps to run ‘html’ test suites. A core API with binding in a range of languages.
A Javascript based Core engine A Javascript based Core engine Natively interacts with browser application
Very simple to use with record & playback. Easy and small API A large API and complex as compared to RC
APIs are not object oriented Less Object oriented APIs Entirely Object oriented APIs
No moving mouse cursors support. No moving mouse cursors support. Supports of moving mouse cursors.
Need to append full xpath with ‘xpath=\\’ syntax Need to append full xpath with ‘xpath=\\’ syntax No need to append full xpath with ‘xpath=\\’ syntax
No listeners supports No listeners supports Supports the implementation of listeners
No support to test iphone/Android apps No support to test iphone/Android apps Supports iphone/Android apps testing

Add appropriate bat/sh script as mentioned in below steps :


Steps to Get Start with Selenium/ Selenium RC


Step a)
Using Selenium IDE, record your test case.

Avoid using “cross domain” testing, for intial recording and preferably only use ‘http’ site, till you figure out the workarounds.

e.g. Use test case that opens this tutorial (on google it searches for selenium tutorial and opens this tutorial) with below link :

Using Selenium IDE

Step b) To ensure that your test case works, play test case using selenium IDE

If necessary, modify the recorded code (e.g. as explained in Quirks section replace click by change timeout or clickAndWait).

Step c) Recording test case should be exported as html file and/or optionally in programming languages like java, perl etc.

You should export it in programming language i.e. java, if you need dynamic capability (e.g. reading data from csv file or database) or your page has lots of flash components. e.g. http://www.adobe.com/devnet/flash/articles/flash_selenium_04.html

Here you can do an attempt to make silverlight work with java and .net.

As compared to the html case, the client code using java also is more stable with less ‘permission denied’ errors.
‘html’ generates nice results and is easy to modify/maintain whereas ‘java client’ code tends to be cryptic.

For the long term prefer the html option (if dynamic capability is not needed)

Step d) Creating a test suite

Create a “Test Suite” (eg suite.html), after saving html test case (eg save as a.html) – as directly a test case can not be played.
Test suite is just a collection of test case, ordered/defined using html table tags.
Initially try to keep test case to the same base URL(ie starting point), if you are adding another test case in the same test suite.

e.g.

Suite.html

Overall Tests
TEST CASE A

Note:
1) In your suite, the first row (e.g Overall Tests) is always considered as Header.
2) A TestSuite is not supported with Selnium RC, go across domains (i.e. the only domain that user would be allowed is for e.g. www.abc.com)
With *chrome for firefox and *iehta for IE, user may be able to work around it.

Follow Next Step?

Skip below steps, if user is happy in running test suite manually in Firefox only with Selenium
IDE (the most stable – with no cross domain/security warnings).

Follow below steps, if user wish to run test suite in IE or want to schedule his/her test suite bat file automatically via inbuilt Microsoft Scheduler on XP or cron on Unix :

Step e) Using Selenium RC, run exported html test case in IE (or firefox)

With below command, run it in command line/bat file :
java -jar selenium-server.jar -multiwindow -htmlSuite “*iexplore” “https://www.abc.com” “C:\suite.html” “C:\results.html”
REM Use *chrome for firefox and try *iexploreproxy

It generated the nice results and in case of failure (The result html file will contained “failed” keyword) user can write a simple script to email the results to him/her self.
With default/inbuilt Microsoft Scheduler on XP, users may also schedule their test suite.

Tips:

1) To change ports in above, user may use -port option.

2) With above options user may have problems in using *iehta (necessary for removing security warning and going across domains).

3)Warning:Its better to use more stable *chrome mode. Else- with this option users are likely to get weird permission denied or some script error or it maybe ask user to download user’s-.do/.faces page. (But note -similar problem may not arise with java client code i.e. using the code that was exported to java).
In brief, as compared to IE, firefox is more likely to be stable for selenium.
In rare cases – User may get some lock errors with firefox.(in which user may try to create seperate profile eg http://seleniumhq.org/docs/05_selenium_rc.html#specifying-the-firefox-profile or in worst case – reboot machine/reinstall it )

Follow Next Step ?

Users may want to export their test case in programming language like java etc, if users want dynamic capability (eg reading from CSV file or reading from database) – else skip next section.

Step f) Run exported test case in programming like java (OPTIONAL).

Go to the directory containing selenium-server.jar, once Selenium RC is extracted/installed.
If user want to use selenium-RC using programming language like java/.net/php etc(most cases), then

user may want to add a bat/sh script to keep Selenium RC always running.

REM set PATH variable to contain location of firefox/IE binary
REM set PATH=%PATH%;C:\firefox/bin
java -jar selenium-server.jar -multiwindow
REM -interactive is more user friendly – but does not work with websites using non frameable pages
REM – if user want to run more then 1 instance, optionally use -port.

Now compile your selenium java client code with junit jar files , use selenium
java client driver, point to above selenium RC server and run it.
Assuming user exported the test case with name “NewTest.java” – user can try to use below bat file (after getting the junit*jar and selelenium-java-client.jar – and creating clases directory in same folder)

——— eg. put below in compileJava.bat —————————-

OPTIONAL Run your exported

This implies the dependence of java (or programming) code on Selenium RC server to be running on same (or other) machine. But every time the “html test case” – launches the “Selenium RC server”.(hence if user run html test cases in parallel, user may need different port)

Step g)(OPTIONAL) – Migrating user test case to Selenium 2.
Since, Selenium 2 is not supported by Selenium IDE (also Selenium 2 does not support HTML test case). User may migrate to Selenium 2, using WebDriverBackedSelenium steps.

Migrating your test case to Selenium 2

Warning: Even though selenium 2 is faster due to native support in browser and all cases may not be supported – certain methods in WebDriverBackedSelenium will take more time.
Hence, it may be better to write clean Selenium 2 tests as shown at: http://seleniumhq.org/docs/03_webdriver.html .

User can choose to export the test in JUnit(WebDriver) in Selenium IDE – and then modify it to use PageFactory pattern.

Get an overview of internal Selenium (Webdriver) architecture at : http://www.aosabook.org/en/selenium.html

So in brief we can say, Selenium is a set of software tools with a different approach to support test automation. Mostly the Selenium QA Engineers preferably use one or two tools that primarily meet the requirements of their project, however learning all the Selenium tools will give you many choices for approaching different test automation problems.

A special thanks should be given to Patrick Lightbody for his invaluable support as a major contributor to Selenium RC. And of course, we must thankful to the Selenium Developers, who have truly designed an amazing tool and without their continued efforts and vision, we would not have such a great tool to pass on to the Testing Engineers.

Go ahead ! try a suitable Selenium automation tool for testing  your web or mobile apps.

Selenium Installation

Pre-requisites

Install Firefox
Install Java jdk: Without Netbeans JEE ot IDE, install jdk (not JRE).

Install (optional) Junit for java rc client (Only if you are using java client, in classpath you may also need to add selenium java client driver)

Installation of Main TOOLS

Install Selenium IDE
See Selenium IDE options in firefox, after installation.

Install Selenium RC
Visit directory containing file ‘selenium-server.jar’- After installation.

If you have any query or required more information related to this blog, you may please Reach us.

Stay Tuned for Latest Updates

Fill out the form to subscribe to our newsletter

Partner with our experienced development team.

Contact Us
Contact Us
Loader