0% found this document useful (0 votes)
14 views6 pages

Selenium Framework for Web App Testing

Uploaded by

Ricardo Oliveira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

Selenium Framework for Web App Testing

Uploaded by

Ricardo Oliveira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ISSN : 2229-4333(Print) | ISSN : 0976-8491(Online) IJCST Vol.

2, Issue 3, September 2011

Framework for Testing Web Applications using Selenium


Testing tool with respect to Integration Testing
1
Prasanth Yalla, 2Dr. L S S Reddy, [Link], [Link] Mastan Rao
1
Dept. of Freshman Engineering [Link], Guntur dist, AP India.
LRBR College of engineering, Mylavaram, Krishna District. AP, India.
2

3
[Link] Freshman engineering, K L University, Guntur Dist., AP, India.
4
Dept. of IST, K L University, Guntur Dist., AP, India.
Abstract environment (e.g. a Java applet) or coded in a browser-supported
Testing has become most important parameter in the case of language (such as JavaScript, combined with a browser-rendered
software development lifecycle (SDLC). The web application mark-up language like HTML) and reliant on a common web
testing is more complicated as it involves different testing strategies browser to render the application executable. Web applications are
and tools, because the tool has to support different characteristic popular due to the ubiquity of web browsers, and the convenience
properties and also different frameworks. Integration testing of using a web browser as a client, sometimes called a thin client.
focuses the verification effort on the smallest unit of software The ability to update and maintain web applications without
design, the software component or module using top-down or distributing and installing software on potentially thousands
bottom-up approach. of client computers is a key reason for their popularity, as is
The main objective of this paper is to propose a framework that the inherent support for cross-platform compatibility. Common
integrates or supports the architectural elements that have been web applications include webmail, online retail sales, wikis etc
already compared with respect to integration testing and finally
doing the same by using the testing tools like QTP, Win runner and Two (2) – Tier Web Application
Load Runner. In this paper, we have compared the architectures Two-tier architecture is client/server architecture, where a request
of two tools and have come-up with different possibilities that to do some task is sent to the server and the server responds by
are leading towards proposing a common framework. Also, in performing the task. A Two-tier architecture is a client/server
order to test any 2-tier web application with respect to Integration application. Client acts as Front End and Server acts as Backend
Testing test cases are required. Here, a framework is proposed like databases.
that satisfies the test requirements.
In our proposed framework, we have taken a tool Selenium under
integration testing and tested several web applications

Key words
Frame work, Web application, Selenium, test case, testing tool,
client, server.
Fig.1.2.3: Two-Tier Architecture
I. Introduction The two-tier model is the one that most computer users are familiar
This paper deals with the testing of Web Applications using a with; it’s the basic foundation of the Internet. Much of the Internet,
testing tool named Selenium under Integration Testing. The main from web browsing to e-mail, is based in some fashion on this
intension of the paper is to test several Web Application and also architecture. The web browser (client) sends a request to a web
to verify the errors if they are present in it. Several test cases server, which determines what the user is looking for and sends
and requirements traceability logs were also considered for this. the information back to the client. Two tier client-server design
derives its name from how it distributes work between client and
Terminologies: server. Clients access databases through the user system interface.
Database management, on the server side, distributes processing
Framework between both client and server. Both tiers, the client and the server,
A framework is a defined support structure in which another are responsible for some of the processing management. Simply
software project can be organized and developed. A framework put, the client uses the user interface to make requests through
may include support programs, code libraries, a scripting language database management on the server side.
or other software to develop different components of a software
project. A web application framework is a software framework that Client Tier
is designed to support the development of dynamic websites, web At the client level we have either a Java client application or a
applications and web services. The framework aims to alleviate web browser as the client. By using a web browser as the client
the overhead associated with common activities performed in Web allows the entire application to be located on the server. The client
development. For example, many frameworks provide libraries for always gets the latest version when they start the application. Also
database access, templating frameworks and session management the client can use any web browser from any location provided
etc and they often promote code reuse. that they can connect to the application server. The client tier
can also consist of an application running on the clients’ desktop
Web Application (usually presenting a rich user interface) and connecting directly
A web application is an application that is accessed over a network or through HTTP to the application server. This requires that the
such as the internet or an intranet. The term may also mean a client have the application installed on their desktop.
computer software application that is hosted in a browser- controlled
w w w. i j c s t. c o m International Journal of Computer Science and Technology 165
IJCST Vol. 2, Issue 3, September 2011 ISSN : 2229-4333(Print) | ISSN : 0976-8491(Online)

Clients Side Elements • You can view Selenium test scripts even in browsers
Html, xml, JavaScript, VB Script that don’t have the Selenium IDE/plug-in installed.
Server Tier : The server is the central computer who gives • Selenium Grid enables you to run tests in parallel on multiple
instructions to the client computer, to make sure everyone can servers reducing the time efforts
logon on any computer (client) can share the resources of sever
like information, peripherals etc The server allow/restrict the II Requirements
client computers to perform any task
Server Side Elements: JSP, ASP, Data Mgmt Components, Testing Requirements
Security Components and other Components like Communication • Select an integration group
Components • Define test conditions
• Determine lowest level module for each test condition
Integration Testing • Reassign condition according to testability
Integration testing (sometimes called Integration and Testing, • Select test conditions for a module's initial test
abbreviated “I&T”) is the phase in software testing in which • All test conditions assigned to a module Grouped into test
individual software modules are combined and tested as a group. cycles
It occurs after unit testing and before system testing. Integration • Construct integration test cycle dependency diagram
testing takes as its input modules that have been unit tested, groups • Estimate effort for testing a test cycle
them in larger aggregates, applies tests defined in an integration • Revise estimates on integration group dependency
test plan to those aggregates, and delivers as its output the diagram
integrated system ready for system testing Integration testing
is of two types Functional Requirements:
i) Top Down Integration In software engineering, a functional requirement defines a
Top-down integration testing is an incremental approach to function of a Software system or its component. A function
construction of program structure. Modules are integrated by is described as a set of inputs, the behaviour, and outputs (see
moving downward through the control hierarchy, beginning with also software).In general, functional requirements define what a
the main control module (main program). Modules subordinate system is supposed to do. Functional requirements are usually in
(and ultimately subordinate) to the main control module are the form of “system shall <do requirement>”. In our paper, the
incorporated into the structure in either a depth-first or breadth- Functional Requirements are Selenium tool, Firefox web Browser,
first manner. Web Application
ii) Bottom Up Integration
Bottom-up integration testing, as its name implies, begins Non – Functional Requirements:
construction and testing with atomic modules(i.e., components In systems engineering and requirements engineering, a non-
at the lowest levels in the program structure).Because functional requirement is a requirement that specifies criteria
components are integrated from the bottom up, processing required that can be used to judge the operation of a system, rather than
for components subordinate to a given level is always available specific behaviours.
and the need for stubs is eliminated. Non functional requirements can be divided into two main
categories 1. Execution qualities, such as security and usability
Objectives and Evolution qualities, such as testability, maintainability etc.
The main objective of this paper is to test any kind of web
application using an automated integration testing tool. We have Core Requirements:
chosen an Integration testing tool named selenium. Generated the • Browse urls
code in different languages that includes JAVA, C# etc. • Render web pages
1.4 Scope: The scope of the testing the Web Application using • Mimic User Actions
Selenium under Integration Testing is as follows: • Validate results
• The user can use any operating system, but should have • Ajax/CSS support
Firefox browser.
• The user should have Selenium tool to test the Web Pragmatic requirements:
Applications. • Language choices
• The user can get the coding in many languages like C#, • Platforms (Browser/OS)
JAVA, Ruby, Python, etc • JS toolkit support
1.5. Purpose: • Distributed tests
The purpose of testing web applications using Selenium because • Scheduled execution
of following features: • Reporting
• Even non-developers can develop tests in the easy-to-use, • Configurability
graphical Selenium IDE and export them as JUnit tests. • Build Integration
• You have a choice of target browsers to run the tests. • Test Creation Environment
Selenium supports browsers like Internet Explorer, Firefox
and Safari. This is in contrast to tools like HTMLUnit and System Requirements Specifications:
Canoo, which have their own implementations of a browser, Software Specifications:
or Watir/Watij, which always use Internet Explorer. Selenium • Operating System: Windows XP, MAC
supports Ajax calls. • Programming Language : C, CPP
• When a test fails, you can send an email with a Screenshot • Graphical User Interface : Java
of the browser. choosing selenium. • Documentation Tool : Ms Access
166 International Journal of Computer Science and Technology w w w. i j c s t. c o m
ISSN : 2229-4333(Print) | ISSN : 0976-8491(Online) IJCST Vol. 2, Issue 3, September 2011

Tools / Platforms: The Selenium architecture mainly consists of two components


• Java complier ( JDK 1.6.0_10) Selenium IDE – The Selenium IDE is a Firefox plug-in that can
• Selenium Tool be used to record tests as they run in the browser. It plays back
• Firefox Browser the tests to simulate a user’s interactions with the browser.
• Rational Rose Selenium Remote Control (RC) – Selenium RC consists of two
components:
[Link] Analysis: 1. Selenium RC Server
System analysis is the dealing with analysis of sets of interacting 2. Selenium RC Client
entities, often prior to their automation as computer systems and Selenium RC server – The server listens for connections from
the interactions with in those systems. Selenium clients. It has the ability to launch a browser and control
the browser to play back tests.
System Study: Selenium client(s) – A client is a set of libraries (in Java, Ruby,
The following are different Modules: PHP, or .NET) that you can use to communicate with the
• Recording-to record the web application Selenium server and send messages to the Selenium server
• Testing- used to test the Web Application to control the browser. The Selenium client runs the test script
• Code Generation- to generate the code that you develop.
• Results-used to report the Runs and Failures occurred while
testing

Existing system:
The existing system is manual or usage of the automated testing
tools like win runner and load runner etc. Manual Testing takes
more time efforts for a window-based or a web-based application.
Even the automated testing tools like win runner have some
limitations. All the test cases that are related to the software
must be tested thoroughly in order to avoid the upcoming errors
during the execution of the software.

Proposed System:
In the proposed System, the process of testing can be implemented Fig. 4.1: Architecture of Selenium
in a different way with the help of integration testing tool Selenium.
Failures can be easily detected. Whenever the test case is executed, Working of the system: Selenium IDE
the code is converted into script in java. Our paper proposes a Selenium IDE is the only flavour of Selenium which allows you
framework with respect to some parameters that support the to record user action on browser window. It can also record user
integration testing and we also proposed a web application that actions in most of the popular languages like Java, C#, Perl, Ruby
can be going to be tested by using a testing tool i.e., Selenium etc. This eliminates the need of learning new vendor scripting
with respect to integration testing that helps to test the application language. For executing scripts created in these languages, you
and also helps to find the errors easily. will need to use Selenium Remote Control. If you do not want
to use Remote Control than you will need to create your test
scripts in HTML format. Selenium can be accessed from tool
--> Selenium IDE in your browser toolbar if the installation is
completed successfully. As compared to most of the test automation
tools it is very simple and lightweight. The small red button on the
right hand side gives you an indication on whether Selenium is in
recording mode or not. Also, Selenium IDE will not record any
operation that you do on your computer apart from the events on
Firefox browser window. So go ahead read your mail, open a word
doc or do anything else, Selenium will record only your actions
on browser. Other options present on the Selenium IDE toolbar
Fig.3.3 Proposed Architecture are related to test execution. Run will execute the tests with the
maximum possible speed, Walk will execute them with relatively
Feasibility Study: slow speed and in step mode you will need to tell Selenium to take
Feasibility is a measure of whether something can be done. small steps. Final button present on the Selenium IDE toolbar is
Feasibility also means that it can likely be completed successfully. the Selenium Test Runner. Test Runner gives you nice browser
Feasibility studies aim to objectively and rationally uncover interface to execute your tests and also gives summary of how
the strengths and weaknesses of the existing business or proposed many tests were executed, how many passed and failed. It also
venture, opportunities and threats as presented by the gives similar information on commands which were passed or
environment, the resources required to carry through, and failed. Test Runner is also available to tests developed in HTML
ultimately the prospects for success. Only. If you open the option window by going to Option, you
will see there are some self explanatory options available. For
IV. DESIGN example, encoding of test files, timeout etc.
Selenium RC
Architecture: Selenium RC allows the test automation expert to use a
w w w. i j c s t. c o m International Journal of Computer Science and Technology 167
IJCST Vol. 2, Issue 3, September 2011 ISSN : 2229-4333(Print) | ISSN : 0976-8491(Online)

programming language for maximum flexibility and extensibility <td>select</td>


in developing test logic. For example, if the application under test <td>choice</td>
returns a result set and the automated test program needs to run <td>label=Three</td>
tests on each element in the result set, the iteration / loop support </tr>
of programming language’s can be used to iterate through the result <tr>
set, calling Selenium commands to run tests on each item. <td>click</td>
Selenium RC provides an API and library for each of its supported <td>//input[@name=’radiogroup’ and @value=’button2’]</td>
languages. This ability to use Selenium RC with a high level <td></td>
programming language to develop test cases also allows the </tr>
automated testing to be integrated with the project’s automated <tr>
build environment. <td>clickAndWait</td>
Automated Integration Testing with Selenium applications: <td>//input[@type=’submit’]</td>
Automated integration tests can be useful particularly <td></td>
for the following types . </tr>
* Existing applications that haven’t run any unit tests (e.g., .
legacy applications) .
* CRUD applications that have a very simple middle tier and <tr>
therefore don’t have/require unit tests <td>waitForPageToLoad</td>
* Applications that have business logic tightly coupled to the <td></td>
environment in which they run (e.g., business logic embedded <td>30000</td>
in DAOs or servlets) </tr>
Options for implementing automated integration tests: <tr>
* Use a different framework for each tier <td>verifyTextPresent</td>
* Use tools, such as Watir or Watij <td>Text entered: test </td>
To create and run integration tests with Selenium, you must <td></td>
complete the following steps: </tr>
1. Use the Selenium IDE to record and play tests. The case above does the following:
2. Export tests created with the Selenium IDE as JUnit tests. 1. Types ‘test’ into a text field with name ‘text’
3. Add the JUnit tests to your Java project in your IDE and run 2. Selects an option with the label ‘three’ from a dropdown box
the tests. named ‘choice’
Optionally, you may choose to run the tests as part of the build 3. Selects a radio button with value ‘button2’ from a radiobutton
process using Ant or Maven as well. group with name ‘radiogroup’
1. Use Selenium IDE to record and play tests. 4. Clicks a submit button
Here are the steps for recording and playing test with Selenium: 5. Waits for the page to load (timeout after 30 sec)
1. Install Selenium IDE in Firefox. 6. Verifies the text ‘test’ is present
2. Start browsing the web application that you wish to test. This test case can be exported as a JUnit test. To export the test
3. Click on the red button in the top-right corner of the Selenium ase in the Selenium IDE, select Options-
IDE. Selenium will record your actions as you click on links, >Format->Java(JUnit)-Selenium RC from the menu.
fill in forms, and submit forms. Here is the jUnit version of above test case [Link](“/
4. Click on the red button in the top-right corner to stop the selenium-1.0/test”); [Link](“text”,”test”); selenium.
recording. Selenium will have recorded the tests. select(“choice”, “label=Three”);
[Link](“//input[@name=’radiogroup’and@
value=’button2’]”); [Link](“//input[@type=’submit’]”);
[Link](“30000”); verifyTrue(selenium.
isTextPresent(“Text entered: test”));

Add the JUnit Tests to your Java project in your IDE and
run the tests.
Import [Link] and selenium-
[Link] into your IDE (Eclipse,
NetBeans, IntelliJ, etc.) project. Create a new JUnit4 test case
and add the code snippet above to your test method.
@RunWith([Link])
Fig. 4.2.1:Selenium IDE showing various steps in a test case @[Link] ({ [Link] })
2. Export tests created with the Selenium IDE as JUnit tests. public class SeleniumTestSuite extends TestSuite {
Selenium saves the test cases as HTML files. Here is a snippet private static SeleniumServer seleniumServer;
from a test case’s HTML file: public static Test suite()
<tr> {return new JUnit4TestAdapter ([Link]);}
<td>type</td> @BeforeClass
<td>text</td> public static void init() throws Exception{
<td>test</td> //Start selenium server
</tr> [Link](“***Starting selenium ***”);
<tr> RemoteControlConfiguration seleniumConfig=new
168 International Journal of Computer Science and Technology w w w. i j c s t. c o m
ISSN : 2229-4333(Print) | ISSN : 0976-8491(Online) IJCST Vol. 2, Issue 3, September 2011

RemoteControlConfiguration(); • Run a Test Suite


[Link]([Link] Selenium • Click the Run All button to run all the test cases in the
erver Port()); seleniumServer = new SeleniumServer( currently loaded test suite.
seleniumConfig); • Stop and Start
[Link](); The Pause button can be used to stop the test case while it
[Link]().init(); [Link](“*** is running. The icon of this button then changes to indicate
Started selenium ***”);} the Resume button. To continue click Resume.
@AfterClass • Stop in the Middle
public static void destroy(){ You can set a breakpoint in the test case to cause it to stop
//Stop selenium server on a particular command. This is useful for debugging your
[Link](“***Stopping Selenium***”); test case. To set a breakpoint, select a command, right-click,
[Link]().getSelenium().stop(); and from the context menu select Toggle Breakpoint.
[Link](); • Start from the Middle
[Link](“***Stopped selenium ***”);}} You can tell the IDE to begin running from a specific
The init method in the JUnit4 test suite above will start the Selenium command in the middle of the test case. This also is used
server. The destroy method will stop the Selenium server. Start for debugging. To set a start point, select a command, right-
the application server with the application that you are trying to click, and from the context menu select Set/Clear Start
test and then run the JUnit4 tests. The JUnit4 init and destroy Point.
methods will be called once only for each run and they will start • Run Any Single Command
the Selenium server. Lastly, the JUnit4 test cases will be run. Double-click any single command to run it by itself. This
is useful when writing a single command. It lets you
immediately test a command you are constructing, when
you are not sure if it is correct. You can double-click it to
see if it runs correctly

[Link] case – K L University

Screen 1: Opening the KLUniversity Website


Fig. 4.2.2 : Selenium tests running as JUnit tests in IntelliJ

V. Implementation
The implementation of the system is described in the following
steps
• Take a URL
• Record the Web Application
• Test the Navigations and hyperlinks
• Obtain the Results

VI. Test Cases


A good test case is one that has high probability of finding an
undiscovered error. A successful test is one that uncovers an
undiscovered error. Test Cases in Selenium are nothing but
recording the Web Application and testing that again using the
Selenium tool. The IDE allows many options for running your
test case. You can run a test case all at once, stop and start it, Screen 2: Testing the Authentication of
run it one line at a time, run a single command you are currently E-Learning Screen
developing, and you can do a batch run of an entire test suite.
Execution of test case is very flexible in the IDE.
To Run a Test Case
• Click the Run button to run the currently displayed test
case.
w w w. i j c s t. c o m International Journal of Computer Science and Technology 169
IJCST Vol. 2, Issue 3, September 2011 ISSN : 2229-4333(Print) | ISSN : 0976-8491(Online)

to 2010. Presently he is working as associate professor, with the


department of Freshman Engineering from 2011 in KL University.
His research interests include Testing tools, Software Engineering,
Web services and SOA. He taught several subjects like Multimedia
technologies, Distributed Systems, Advanced Software
Engineering, Object Oriented Analysis and design, C programming,
Operating Systems , Database management systems, UML etc.
He is the Life member of CSI.

Dr [Link] received his Ph.D from BITS, PILANI and


presently Working as DIRECTOR, Lakireddy
Bali Reddy College of Engineering,Mylavarm
Krishna district. He is having more than 30 years
of experience in teaching. Previously he Worked
in various prestigious institutions like CBIT, Birla
Screen 3: Testing the Functionality of attendance Institute of Technology & Science(BITS),
PILANI , MVSR (Matrusri) Engineering College,
VII. Conclusion: Hyderabad ,[Link] Engineering College, Vijayawada,as
In this paper, we used an integration testing tool called Selenium a principal,[Link] of Engineering. He got many AWARDS/
that tests the automated web applications. In our proposed HONORS like Chairman Academic Council KLCE
framework, Selenium under integration testing tool tests several (Autonomous),Recognized guide for guiding scholars of Ph.D in
web applications and generated the code in different languages Computer Science of Mysore University, Acharya Nagarjuna
that includes JAVA, C# etc. Several test cases and requirements University &JNTU, Hyderabad, Chairman, board of studies
traceability logs were prepared that support our paper. We can even Computer Science and Engineering, and Information Technology,
extend the work by adding some new properties to the testing tool Acharya Nagarjuna University, Chairman,CSI Chapter-
and new languages that will be proposed later Vijayawada. Senior Member, IEEE Computer Society. Member,
Expert Panel of DOEACC Society and many more.
VIII. Bibiliography

BOOKS: [Link] received his MCA from IGNOU ,New Delhi and
1) Roger S .Pressman, ‘Software Engineering- A Practitioner’s [Link] in Computer Science and
Approach’, 5th Edition, McGraw Hill International. Engineering from Acharya Nagarjuna University
2) Practical software testing: a process-oriented approach By and presently pursuing the Ph.D. in K L
Ilene Burnstein. University, Guntur (Dist),AP, India. He is
3) Shari, Lawrence Fleeger, “Software Engineering – Theory working presently as an Associate professor in
and Practice”, Pearson Education Asia. the department of Freshman Engineering in KL
University .He is having 16 years Experience
WEBSITES: in Teaching in reputed institutions. His research
1) [Link] interests include Software Engineering, Datamining. He is life
2) [Link] member of professional bodies like CSI, ISTE. He taught various
3) [Link] subjects in computer science and engineering like software
4) [Link] engineering, computer organization, Database Management
5) [Link] systems, Cryptography and network security, Digital Logic
presentation design, UML ,OOPS etc.
6) [Link]
7) [Link]
8) [Link] T SubhaMastan Rao received his B-Tech degree in Information
Integration+testing+framework Science and Technology from Acharya
9) [Link] Nagarjuna University, Guntur (Dist), India in
Selenium 2001, the [Link]. degree in Computer Science
10) [Link] and Technology from Bharat University in
2008, and presently pursuing the Ph.D. degree
in Web Usage mining from Acharya Nagarjuna
Prasanth Yalla received his [Link]. Degree from Acharya University Guntur (Dist), India. He is working
Nagarjuna University, Guntur (Dist), India in as assistant professor, with Department of
2001,the [Link]. degree in Computer Science Information Science and Technology. His research interests
and Engineering from Acharya Nagarjuna include Testing tools and web usage mining. At present, He is
University in 2004, and presently pursuing the engaged in Data mining concepts and techniques.
Ph.D. in Web services and SOA from Acharya
Nagarjuna University, Guntur (Dist), India. He
was an associate professor, with Department of
Information Science and Technology in KL University, from 2004
170 International Journal of Computer Science and Technology w w w. i j c s t. c o m

You might also like