You are on page 1of 26

1.

Introduction:

The goal of software testing is to find defects in software as early as possible. Software testing
consumes 30 to 60 percent of all life cycle cost, depending on product criticality and
complexity [1].With the development of internet technologies, web applications became more
popular. Nowadays large number of software systems has been implemented as web
applications. The quality of these web applications is one of the important factors while
deploying these web applications [3]. So to increase the quality of software, testing plays an
vital role. Software development cycle becomes shorter and shorter; this makes the software
testing more difficult. Manual testing is a time consuming process and it require human
intervention. So to avoid these problems, automation testing came into picture.

Automation testing means to automate the testing process or activities including design and
execution of test scripts and use effective software automation tools [4]. Automation testing
improves the quality of software testing and minimizes the human intervention in software
testing process. To support these tasks there are various commercial and open source tools
available, such as Watir, JMeter, Selenium, QTP and many other. The Selenium automation
tool considered most popular and open source tool for testing the web applications [7].In this
paper we have proposed automation testing framework based on the selenium webdriver and
TestNG tool.

1
2. Automated vs. Manual Testing:

Automation is the best way to make sure that tests are run often. Automating
tests also means that developers can develop a test script before the program is written.
This is the ideal process because the developer can then confirm as soon as the program
is written that it does what was expected of it with the click of a button. Each time you
write an automated test, you might have missed the chance to perform 3 manual tests. [4]
In general, creating the original automated test script with encoded verifications that test
certain elements of the program can often be more intricate than simply clicking the
links and verifying with one look that everything has loaded properly. That being said,
with the knowledge that these scripted tests can be run over and over again, it is best to
trust automation to do the job.

Consider the fact that the tester, who may or may not be involved in
development, is not always able to pick up on the finer details of the program that might
have changed. Instead of having to remember every aspect of the program and make
sure everything is still in order, the developer can trust their previously constructed
script to do so. In future cases, the need to manually test the program would no longer be
necessary. Automated testing comes in especially handy with web software. If you were
testing a shrink-wrap product whose product direction and code base has changed wildly
in the last few months you may not even have time to try all the obvious tests once. In
the time you would spend automating your tests, you could find at least one completely
new bug. In this case, the cost of automation is high. There are a few questions one
should ask oneself when determining whether or not to automate tests. Is the feature a
core/critical feature? Is the test tedious and error prone? Will my test script verify results
via a fragile method (screen capture) or a sturdy method? Is the feature I am trying to
automate undergoing a lot of churn? When this script fails, how easy will it be for me to
investigate the failure? One thing that will cause test scripts to fail just about faster than
anything else is the product changing. This is why refactoring tests is so important.

2
3. Basics of Selenium:

Selenium is composed of multiple software automation tools such as, Selenium IDE,
Selenium RC (selenium 1.0), and Selenium webdriver (selenium 2.0) [7]. Selenium IDE is an
integrated development environment to build the test scripts. It is a Firefox plug-in allow you
to record edit and debug the selenium test cases [4]. It records all actions performed by the end
user and generate the test scripts. Selenium remote control (RC) was main selenium project for
long time. Selenium RC is slower than the selenium webdriver because it uses the java script
program called selenium core [7]. Selenium RC requires to start the server before executing the
test scripts. It doesn’t support the Ajax applications. To avoid the limitations of selenium RC,
selenium webdriver has been invented by merging selenium and webdriver.
Selenium webdriver is also known as selenium 2.0 [7]. Selenium webdriver directly
communicate with the browser, so selenium webdriver is faster than selenium RC. Selenium
webdriver supports multiple web browsers and also support for Ajax applications. The main
goal of the selenium webdriver is to improve support for modern web application testing
problems. Selenium webdriver supports multiple languages to write the test scripts. Selenium
webdriver’s API is simpler than the selenium RC’s [5]. However, despite all advantages of
selenium web driver, it has some limitations when testing the web applications. Selenium
webdriver does not have built in functionality to generate the screenshots for failure test cases.
Selenium webdriver does not have built in capability to generate the test results. It depends on
third party tools to generate the test reports. This limitation can be avoided by using TestNG
framework.

3
4. Selenium IDE:

When it comes to automated testing tools, it seems that in fact Selenium will
get the job done best for the lowest cost, (time-wise and financially). Previously, the
common statement with regard to testing JavaScript applications was “write once, test
everywhere.” Selenium makes this task less of a nuisance as it can be used across
multiple platforms. Writing tests with Selenium makes it very simple to perform tests
often and maintain them. It is clear that automated tests of these kind save a lot of time in
the long run. Using browser recording playback and JavaScript conveniences such as
loops, you will find that Selenium, and tools like it, will save plenty of time when it
comes to testing web applications.

Selenium IDE in an integrated development environment which tests code


while integrating browser activity. The main goal of writing these types of tests is to
mimic user actions to determine if the database and web server are behaving as expected
as they carry out the users’ commands. Verifications are the heart of selenium tests.
These commands are a way of knowing what part of the application is being tested and
what the user expects the browser to present. Writing tests is relatively easy with
selenium. The end product of a selenium test can be converted to any language, however,
by default, selenium scripts are simply a combination of “Selenese” commands in an
HTML format. However, by downloading or creating a user extension, as I did,
JavaScript commands may also be implemented.

4
Fig 1 . Selenium ID

5
Fig 2. Selenium inside Internet Explorer.

4.1. Getting started:

Setting up Selenium is easy, although there is a catch. The basic installation of Selenium
must be hosted by the same web server as the Application Under Test (AUT). This restriction is
due to the fact that JavaScript has built-in security against cross-site scripting. [3] After
installation, the user simply needs to begin writing and running tests.

4.2. Writing good tests:

Selenium tests are not difficult to write. Because Selenium allows the identification of
elements using the browser’s DOM object, the test can be written using specific identifiers of
the necessary element, such as name, id, or xpath:

6
Table 1: Input data for a Selenium Test

Type name=theField Text to submit


clickAndWait id=SubmitButton
assertText xpath=//h1/span Success!

4.3. Selenium IDE-Features:

Selenium IDE is divided into different components, each having their own features and
functionalities.We have categorized seven different components of Selenium IDE, which
includes:

1. Menu Bar
2. Tool Bar
3. Address Bar
4. Test Case Pane
5. Test Script Editor Box
6. Start/Stop Recording Button
7. Log, Reference Pane

7
Fig 3 : Selenium IDE

4.3.1. Menu Bar:

Menu bar is positioned at the top most portion of the Selenium IDE interface. The most
commonly used modules of menu bar include:

o Project Name
It allows you to rename your entire project.

o Open Project
It allows you to load any existing project from your personal drives.

o Save Project
It allows you to save the entire project you are currently working on.

8
4.3.2. Tool Bar:

The Tool bar contains modules for controlling the execution of your test cases. In addition, it
gives you a step feature for debugging you test cases. The most commonly used modules of
Tool Bar menu include:

o Speed Control Option


It allows you to control the execution speed of your test cases.

o Step Feature
It allows you to "step" through a test case by running it one command at a time. Use for
debugging test cases.

o Run Tests
It allows you to run the currently selected test. When only a single test is loaded "Run
Test" button and "Run all" button have the same effect.

o Run All
It allows you to run the entire test suite when a test suite with multiple test cases is
loaded.

4.3.3. Address Bar:

This module provides you a dropdown menu that remembers all previous values for base URL.
In simple words, the base URL address bar remembers the previously visited websites so that
the navigation becomes easy later on.

4.3.4. Test Case Pane:

This module contains all the test cases that are recorded by IDE. In simple words, it provides
the list of all recorded test cases at the same time under the test case pane so that user could
easily shuffle between the test cases.

At the bottom portion of the Test Case Pane, you can see the test execution result summary
which includes the pass/fail status of various test cases.
9
Test Case Pane also includes features like Navigation panel which allow users to navigate
between test cases and test suites.

4.3.5. Test Script Editor Box:

Test Script Editor Box displays all of the test scripts and user interactions that were recorded by
the IDE. Each user interaction is displayed in the same order in which they are performed. The
Editor box is divided into three columns: Command, Target and Value.

Fig 4. Test Script Editor Box

o Command:
Command can be considered as the actual operation/action that is performed on the
browser elements. For instance, if you are opening a new URL, the command will be
'open'; if you are clicking on a link or a button on the web page, then the command will
be 'clicked'.

o Target:
Target specifies the web element on which the operation has to be performed along with
10
a locator attribute. For instance, if you are clicking on a button called javaTpoint, then
the target link will be 'javaTpoint'.

o Value:
Value is treated as an optional field and can be used when we need to send some actual
parameters. For instance, if you are entering the email address or password in a textbox,
then the value will contain the actual credentials.

4.3.6. Start/Stop Recording Button:

Record button records all of the user actions with the browser.

4.3.7. Log, Reference Pane:

The Log Pane displays the runtime messages during execution. It provides real-time updates of
the actions performed by the IDE. It can be categorized into four types: info, error, debug and
warn.

The reference Pane displays the complete detail of the currently selected selenese command in
the editor.

11
5. Selenium Remote Control (Selenium RC):

Selenium RC was the flagship testing framework of the whole Selenium project for a long time.
This is the first automated web testing tool that allowed users to use a programming language
they prefer. As of version 2.25.0, RC can support the following programming languages:

 Java
 C#
 PHP
 Python
 Perl
 Ruby

12
6. Selenium WebDriver:

The WebDriver proves itself to be better than both Selenium IDE and Selenium RC in many
aspects. It implements a more modern and stable approach in automating the browser's actions.
WebDriver, unlike Selenium RC, does not rely on JavaScript for Automation. It controls the
browser by directly communicating with it.

The supported languages are the same as those in Selenium RC.

 Java
 C#
 PHP
 Python
 Perl
 Ruby

Selenium WebDriver performs much faster as compared to Selenium RC because it makes


direct calls to the web browsers. RC on the other hand needs an RC server to interact with the
browser.

WebDriver has a built-in implementation of Firefox driver (Gecko Driver). For other browsers,
you need to plug-in their browser specific drivers to communicate and run the test. Most
commonly used WebDriver's include:

o Google Chrome Driver


o Internet Explorer Driver
o Opera Driver
o Safari Driver
o HTML Unit Driver (a special headless driver)

13
7. Selenium IDE- First Test Case:

In this section, you will learn how to create a basic test case in Selenium IDE.

The entire test script creation process in Selenium IDE can be classified into three steps:

1. Recording (recording user interactions with the browser)


2. Playing back (executing the recorded script)
3. Saving the test suite

7.1. Recording:
o Launch Firefox browser.
o Click on the Selenium icon present on the top right corner on your browser.

fig 5. Recording

o It will launch the default interface of Selenium IDE.

o Rename the project as "Demo Test".


o Rename the test case as "javaTpoint_test".

14
fig 6.

o Click on the "Start Recording" Button present on the top right corner on the IDE to start
recording the test case.

fig 7.

15
o Go to your Firefox browser and open URL:www.google.com
o It will redirect you to the Google search engine page.
o Type "Java Tutorials" in the Google search box.

fig 8.

o Hit enter to get the search results.


o Click on the link "Java Tutorial" provided under the
URLhttps://www.javatpoint.com/java-tutorial

16
fig 9.

o It will redirect you to the javaTpoint's Java tutorial web page. Meanwhile, you will get
the notifications of the actions performed by the IDE at the extreme right corner of your
web browser.
o Now, go the IDE and click on the "Stop Recording" button to stop recording your
actions further.

fig 10.

o The Test Editor box now contains the list of all of your interactions with the browser.

17
fig 11.

Now, we will proceed to the next step which includes executing the recorded script.

7.2. Playing Back:

o Click on the "Run Current Test" button present on the tool bar menu of the IDE.
It will execute all of your interactions with the browser and gives you an overall
summary of the executed test script.

18
fig 12.

o The Log pane displays the overall summary of the executed test scripts.

fig 13.

19
7.3. Saving the test suite:

o Click on the save button present on the extreme right corner of the menu bar.

fig 14.

o Save the entire test suite as "Demo Test".

20
fig 15.

o The test suite can be found at the location provided in the above steps. Notice that the
test script is saved in .side format.

21
8. Selenium Limitations:
o Selenium does not support automation testing for desktop applications.
o Selenium requires high skill sets in order to automate tests more effectively.
o Since Selenium is open source software, you have to rely on community forums to get
your technical issues resolved.
o We can't perform automation tests on web services like SOAP or REST using Selenium.
o We should know at least one of the supported programming languages to create tests
scripts in Selenium WebDriver.
o It does not have built-in Object Repository like UTF/QTP to maintain objects/elements
in centralized location. However, we can overcome this limitation using Page Object
Model.
o Selenium does not have any inbuilt reporting capability; you have to rely on plug-ins
like JUnit and TestNG for test reports.
o It is not possible to perform testing on images. We need to integrate Selenium
with Sikuli for image based testing.
o Creating test environment in Selenium takes more time as compared to vendor tools like
UFT, RFT, Silk test, etc.
o No one is responsible for new features usage; they may or may not work properly.
o Selenium does not provide any test tool integration for Test Management.

22
9. Conclusion:
When developing web software, the ultimate goal of the tester or developer is to ensure
that the application is tested often and thoroughly. More often than not, creating
automated test scripts is the best way to be sure that this goal is accomplished. In
particular, the developer wants to be sure to create maintainable test scripts that will last
through the many changes that applications undergo. If modifying or refactoring the test
script does become necessary, there are ways to make sure this job is done quickly and
correctly. The main way is to avoid test duplication. By keeping specific tests self-
contained, they can be reused in several places and only one modification would be
necessary for all instances. An Open Source test tool, Selenium IDE has many
advantages, including an easy to use record and playback tool, and the ability to test
JavaScript inside of the browser. However, as test cases can only be run sequentially a
cannot be embedded in one another in the IDE, writing higher level test scripts can
sometimes be difficult. In addition, the log, which reveals whether or not tests
have run successfully, evidently cannot be exported. However, all in all, the user
friendly nature and the ability to customize commands via user extensions make
Selenium IDE an ideal test suite development environment in many ways.

23
10. References:

1. MacarioPolo,PedroReales,MarioPiattini. Computing Test Automation; IEEE Software,


VOL. 30, NO. 1, January 2013.

2. Maurizio Leotta,DiegoClerissi,FilippoRicca,CristianoSpadoaro. Comparing the


Maintainability of Selenium WebDriver Test Suites Employing Different Locators;
ACM,2013.
3. AndrzaM,Giesel A. etl. Extension of Selenium RC Tool to Perform Automated
Testing with Databases in Web Applications; Automation of Software Test
(AST), 2013 8th International Workshop ,2013.125–131.
4. Sherry Singla, HarpreetKaur. Selenium Keyword Driven Automation testing
Framework, International Journal of Advance Research in Computer Science and
software Engineering, VOL. 4,Issue 6,2014.
5. RigzinAngmo,Monika Sharma. Selenium Tool:A web based Automation testing
Framework. International Journal of Emerging Technologies in Computational
and Applied Science,2014.
6. Z. Wanadan,J. Ninkang,Z. Xubo. Design And Implementation Of A Web
Application Automation Testing Framework; Ninth International Conference On
Hybrid Intelligent Systems, 2009.
7. Selenium Documentation.[Online].(http://www.seleniumhq.org). (Accessed 15 DEC.
2014).
8. TestNG Documentation.[Online].(http://www.testng.org). (Accessed 25 DEC. 2014).
9. F. Wang., Du. A Test Automation Framework Based on WEB.IEEE/ACIS
11th International Conference on Computer and Information Science,2012,
683-687.

24
25
26

You might also like