testing of web applications ppt

66
TESTING WEB APPLICATIONS Presented By: Janardan Verma M.Tech 1’st Department of Computer Engineering National Institute of Technology, Kurukshetra

Upload: nitesh-kumar-grover

Post on 07-Nov-2014

134 views

Category:

Documents


4 download

DESCRIPTION

Presentation on how to test web applications its framework,architecture of testing tools and demos of web testing using selenium automated testing tool.

TRANSCRIPT

TESTING WEB APPLICATIONSDepartment of Computer Engineering National Institute of Technology, Kurukshetra

Presented By: Janardan Verma M.Tech 1st Year 3125511

Outlines Introduction Challenges In Web Application Testing Functional and Non- Functional Testing Modeling Web-based Applications Architecture of Web application Testing Tool Techniques For Future Web Application Testing A Test Automation Framework Selenium Automated Testing Tool Conclusion References

Introduction A web application is a system, with a client-server or

multi-tier architecture, with these characteristics. A wide number of users distributed all over the world and accessing it concurrently. Heterogeneous execution environments composed of different hardware, network connections, operating systems, Web servers and Web browsers.

Cont. The main aim of testing a Web application is to

discover failures in the required services and verify the application behavior with specified requirements. Due to large number of different elements and lot of

interdependent components, many challenges during the testing appears.

Challenges In Web Application Testing Users :

Different skills sets, os, devices, connection speed etc Locales:

Internationalization issues such as language translations, time zone considerations, and currency conversions For eg. in case of e-commerce Web application lots of issues like tax calculation,

shipping costs determination, transactions etc

Testing Environments:

Need duplicate production environment i.e. Web servers, application servers, and database servers to ensure the quality and test the Web applications.

Cont Security:

Open to world after deployment Integration:

Components developed by different vendors and integrated to the applications according to the business need. S0 this integration can also result the misfunctioning. Compatibility issues:

Due to browsers and integration

Functional TestingChecking that application is working as per the specifications.

Test links Test Forms Test Cookies

Test HTML and CSS Test Database

Non-Functional Testing Performance testingo

Load testing o Stress testing Compatibility testing Usability testing Security testing Interface Testing

Load Testing Measuring QoS performance based on actual

customer behavior Script recorder records the communication Load generator replay recorded scripts concurrently Hardware and software statistics will be monitored and collected . At last, all these statistics will be analyzed and a load testing report will be generated.

Log:RequestReq1 Req2 Req3 Req4 Req5 Req6

URLGET /login.jsp POST /verify.jsp GET /index.jsp GET /viewfolder.jsp GET /download.jsp GET /upload.jsp

Occurs3 3 130 130 30 20

Req7Req8 Req9

POST /upload.jspGET /delete.jsp GET /logout.jsp

2010 2

ContGeneral Session are view, download, upload and delete

we can easily get the proportion of all the General Sessions by these equations.

Modeling Web-based ApplicationsModels represent the components of the application under test and their interconnections. UML Model Finite State Machine Model

Meta-Model of a Generic Web Application

Model with a Form

Modeling Using FSM

A cluster is collections of Web pages that implements some logical function.

An LWP is either an entire physical Web page or the

portion of a Web page that accepts data from the user through an HTML form.

Testcase ApproachPhase 1: Build a model of the Web application. Partition the Web application into clusters Define logical Web Pages Build FSMs for each cluster Build an FSM to represent the entire Web application Phase 2: Generate test from the model defined in phase 1 Generate tests as sequences of transitions Identify values for inputs

Top Level FSMSS: Student Services PS: professor Services TS: Teaching Assistant Services W0: Login Screen Off: Logoff

Node Cluster ExplanationSS1: Select Service 1 - Menu of named services SS2: Select Service 2 - List of navigation buttons I: Info Form G: Grades - View Grades and Grades pages ETA: Email TS EP: Email Prof H: Submit homework C: View course info Pages

Architecture Of Web application Testing Tool Interface: Implements user interface providing the

access to the functions offered by the tool. Service: The service implements the tool services. Repository: It includes the relational database

storing the W A model, test cases, and test logs, files of instrumented web pages, driver web pages, stub web pages, and test reports.

Services Test Case Manager Driver and Stub Generator Code Instrumentation Manager

Test Result Analyzer Report Generator

Test Case Manager:

Two main functions

Test case design Testing documentation It also allows inserting, modifying, deleting, and browsing test suite, test case, and test log data.

Driver and Stub Generator: It has set-up, execution and clean-up steps. These steps are performed using the driver web pages,

produced by the Driver Generator on the basis of the test model and the test case descriptions stored in the repository

Code Instrumentation Manager:

This component is responsible for instrumenting

client and server web pages by inserting scripts in order to carry out a dynamic analysis of the W A when the test cases are executed. This information will be stored into a tagged file and

used to evaluate the coverage obtained by the test execution.

Test Result Analyzer:

Parses the tagged files generated during the execution

of the instrumented web pages, and extracts the data items making up the test logs. Compares the actual results against the expected

values of output variables, output actions, exceptions, and environment state obtained after the test execution

Report Generator:

First report describes the list of components of the

web page The second report describes, for each web page, both the set of exercised components and the set of components that were not exercised during the test

Techniques For Future Web Application Testing Model-Based Testing Search-Based Testing

Search-Based Testing Uses search Algorithms to test data generation Suitability of search algorithms for testing is based on

ability to produce effective solutions for complex and poorly understood search spaces with many dimensions Dimensions of the search spaces are directly related to the number of input parameters. Search-based testing can be improved by applying genetic programming to web applications

Steps An appropriate fitness function is defined for the test

aim, and some search algorithm has been selected. An initial set of individuals (i.e., test data) is generated, usually at random For each testdata set test is executed and monitored and the fitness value is determined Test data with high fitness values are selected with a higher probability than those with a lower value

Cont Then by combination and mutation processes new

offspring test data is generated. New population of test data is formed by merging offspring and parent individuals. The process repeats itself, starting with selection until the test objective is fulfilled or another given stopping condition is reached

ContA European project EvoTest has successfully applied search-based testing techniques to various real-world complex systems Queues that fill up when some components are faster

than others, or the clients generate a lot of traffic Races between components resulting in different results for the same tests Deadlocks that occur due to a set of components

Test Automation Framework A automation framework should be compatible with

the same type of many applications, does not need so much modification. It should supporting a variety of Web browser for solving web applications compatibility across the browsers. It should provides testers with a simple interface. Testers should be able to configure different browsers conveniently for web application test.

TEST DATA

TEST CASE

TEST TYPE

TEST CONFIG Run Test Action

TEST SCRIPT

TEST REPORT

Return Result

WEB APPLICATION

Components of Automation FrameworkThe integrated auto testing framework includes five components. Model Translator Actionworker Comparator TestresultCollector

Translator Translator has two levels. Translate the test case which

is prepared by tester to a tool test case which can be recognized by a specific test tool. Get a translator name by getTranslatorName() To translate the testcase to a scope testcase with a

specific translator name by getTranslatorInstance() and translate()

ActionWorkerThis component creates a specific actionWorker and then performs specific actions. Gets a actionworker name by getActionWokerName() Gets a actionworker instance by

getActionWorkerInstance() Perform action by doAction()

Comparator This component collects the test result and collects

expected result, and compares both Get an instance test result by collectTestResult() from the getTestResultCollectorInstance() with getTestResultCollectorName() To collect the expected result of the running test case by collectExpectedResult() Compare the test result with the expected result by compare() and then give the result of comparing.

Some testing automation Tools Rational Functional Tester (RFT)-IBM,RcPlay Selenium-RcPlay framework JSpec

WebLight-html link ASPUnit-Asp Adobe Browser Labs Rational AppScan- IBM tool that supports automatic

test creation and modification. Cactus-Jsp test framework from Apache

Selenium Overview Selenium is a framework for testing websites. Selenium tests run directly in a browser A wide array of browsers supported by Selenium are

Internet Explorer, Mozilla Firefox on Windows, Linux, and Macintosh Selenium uses JavaScript to embed a test automation engine in the browser It work with any JavaScript-enabled browser Support for many other languages Java, Ruby, Python

Selenium VariantsCan be used in isolation or in combination to create complete automation suite for web applications. Selenium Core:

A JavaScript library that can interact with the page, allowing automatically rerun tests against multiple browsers. That library eventually became Selenium Core Selenium IDE Selenium Remote Control Selenium Web Driver

Selenium Grid

Selenium

IDE

CORE

RC

Record Mode

Bot Mode: HTML tables

Driven Mode. Test Case in different Language

Selenium IDE Firefox plug-in Easy to generate test cases Provides record and playback functionality.

Provides the ability to debug test scripts. Auto complete common selenium commands. Export tests in different formats like Java, Ruby,

Python and so on. Supports user extensions.

Limitations of IDE Browser Selenium IDE is only available for the Firefox.

Language Selenium IDE can execute scripts created in Selenese

only.

Selenium Commands Selenese Actions are commands that generally manipulate the

state of the application, like click this link and select that option. If an Action fails, the execution of the current test is stopped. Accessors examine the state of the application and store the results in variables, e.g. storeTitle Assertions are like Accessors, but they verify that the state of the application conforms to what is expected, e.g. verify that this checkbox is checked.

Commands open( url ) Opens a URL in the test frame. This accepts both relative and absolute URLs

Open /mypage Open http://localhost:8080/

click( elementLocator ) Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), use "clickAndWait".

Click Checkbox ClickAndWait submitButton

Cont.. type( inputLocator, value ) Sets the value of an input field. Can also be used to set the value of combo boxes, check boxes, etc

Type nameField John Smith typeAndWait textBox something

select( dropDownLocator, optionSpecifier ) Select an option from a drop-down, based on the optionSpecifier

Select dropDown Australian Dollars Select dropDown index=0 selectAndWait currencySelector label=In*ian

Building Test Cases NEW NEW open /cyberspace/ clickAndWait link=Domain Search type id=domain asc

Testsuite

Sample Selenium Test Suite Test Cases for De Anza A-Z Directory Links A Links B Links C Links D Links

goBackAndWait verifyTextPresent type type id=phone Welcome to My Home Page (555) 666-7066

Id=address1

delhi

50

Selenium Locators id fastest method

name link dom xpath slowest method

Example Execution

Selenium Remote Control A server, written in Java and available on all the

platforms. Acts as a proxy for web requests from them. Have client libraries for many popular languages Bundles Selenium Core and automatically loads into the browsers Automatically launches and kills browsers.

Install & Start Ensure that JDK is present on the machine and is in

the class path. Unzip to any directory on your file system. Change directory to the Selenium Server on the command line or terminal. Start Selenium Server(open command prompt, go to

directory where selenium-server.jar is present.

java -jar selenium-server-standalone-2.31.0.jar

Testing With Selenium-RC Client Libraries:

Client libraries provide the programming support so that we can run Selenium commands from a program of our own design. Different client libraries for supported languages.

Cont Download Client Library(java) Open any desired Java IDE (Eclipse, NetBeans,etc.) Create a java project

Add the selenium-java-.jar files to

project as references. Run Selenium server Export test script from Selenium-IDE in any language and use for selenium-RC or learn API.

Example Execution

Selenium Web Driver Direct calls to the browser using each browsers native

support for automation. How these direct calls are made and the features they support, depends on the browser Selenium-RC worked the same way for each supported

browser. It injects JavaScript functions into the browser when the browser was loaded and then used its JavaScript to drive the AUT within the browser.

What is Selenium-Grid Multiple tests can run at parallel against different

machines running different browsers and operating systems. It allows running tests in a distributed test execution

environment.

Limitations If website has lots of Flash component, Selenium

automation is tricky. Automation of web page involving multiple frames. Testing functionality provided by third party tools out of scope of test automation tool. Performance testing can not be done.

Conclusion All the testing aspects that are directly dependent on

the implementation technologies have to be adapted to the heterogeneous and dynamic nature of the Web applications. Web applications develops very rapidly. So it is urgent to improve the older testing techniques, so as to gain better quality and adaptability. Future work will address a further experimentation involving a wider set of web applications by using other testing coverage criteria .

References1. Sneed,Harry M.,"Testing a Web application" IEEE International Telecommunications Energy Conference, INTELEC, Page(s):3-10, 2004 2. G. A. Di Lucca, A. R. Fasolino, F. Faralli, and D. Carlini., Testing web applications, IEEE International Conference on Software Maintenance(ICSM), pp310-319, 2002 3. Holmes, Antawan ; Kellogg, Marc, "Automating functional tests using Selenium ", Proceedings of Agile 2006 Conference, Page(s):269-275, 2006 4. F. Ricca and P. Tone!la, "Analysis and Testing of Web Applications", Proc.of International Conference on Software Engineering ICSE 2001, IEEE Computer Society Press,Page(s): 25-34, 2001 5. D. Lowe, B. Henderson-Sellers, Characteristics of Web Development Process, International Conference Advances in Infrastructure for Electronic Business, Science, and Education on the Internet. SSGRR 2001 6. Marn, Beatriz ; Vos, Tanja E J ; Giachetti, Giovanni ; Baars, Arthur I. ; Tonella, Paolo,"Towards testing future Web applications" IEEE International Conference on Research Challenges in Information Science (RCIS),Page(s): 1-12, 2011

References9. Kuk, Seung Hak ; Kim, Hyeon-Soo, "Automatic Generation of Testing Environments for Web Applications "International Conference on Computer Science and Software Engineering,Page(s): 694 - 697, 200810. Xu, Lei ; Xu, Bao-wen,"A framework for Web applications testing", International Conference on Cyberworlds, Page(s): 300 - 305, 2004 11. Khanna, Rashmi,"A Test Automation Framework Based on WEB", IEEE/ACIS International Conference on Computer and Information Science (ICIS), Page(s):683-687, 2012

12. http://www.ibm.com/developerworks/library/wa-webapptesting13. http://www.linuxjournel.com/artical/10601