Testing Web Applications. Plan The presentation covers: Selenium framework Spring MVC Test framework HttpUnit framework.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Test Automation with Selenium
Pubman and Selenium tests. What is Selenium Selenium is a suite of Web application test automation tools for any browser on any operating system –Firefox,
Automating with Open Source Testing Tools Corey McGarrahan rSmart 01-July-08.
Selenium HP Web Test Tool Training
Test Automation Framework Ashesh Jain 2007EE50403 Manager Amit Maheshwari.
The Web Warrior Guide to Web Design Technologies
Server-Side vs. Client-Side Scripting Languages
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Test Web applications using Selenium
Selenium – Testing Tool. What is Selenium? Selenium is a robust set of tools that supports rapid development of test automation for web-based applications.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
Automation using Selenium Authored & Presented by : Chinmay Sathe & Amit Prabhu Cybage Software Pvt. Ltd.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
CST JavaScript Validating Form Data with JavaScript.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Chapter 11 Adding Media and Interactivity. Flash is a software program that allows you to create low-bandwidth, high-quality animations and interactive.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Selenium automated testing in Openbravo ERP Quality Assurance Webinar April 8th, 2010.
Val Kravets, Luis Sanchez, Allen Chung, Phillip Anderson, Leyla Norooz, Brian Ramnarian, Todd Watson.
Robot Framework – Basic Level. Date: Version:1.0 Page 1.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Testing Web applications. Selenium What is Selenium? Selenium is a suite of tools to automate web application testing across many platforms Tests run.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 HTTPUNIT Lauri Peterson Technology Partners, Inc
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
Web Automation Testing With Selenium By Rajesh Kanade.
BIT 286: Web Applications Automated Web Testing. Selenium  Selenium Is moving from being Firefox based to being more of a 'normal desktop' program that.
Pubman and Selenium tests. What is Selenium Selenium is a suite of Web application test automation tools for any browser on any operating system –Firefox,
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Automated Smoke Testing on the JVM with Geb João SILVA (GS-AIS-EB) 1st Forum 29th of September, 2015 e-Business Section AUTOMATED SMOKE.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Selenium January Selenium course content  Introduction (Session-1)Session-  Automation  What is automation testing  When to go for automation.
Introduction Selenium IDE is a Firefox extension that allows you to record, edit, and debug tests for HTML Easy record and playback Intelligent field selection.
Lec 18 Web with Selenium 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Lecture 16 Testing Web Applications 10/23/
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
HTTPUNIT. What is HTTPUNIT HttpUnit is an open source software testing framework used to perform testing of web sites without the need for a web browser.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Selenium Date:06/10/2009. May 13, Agenda Testing – Test Automation Selenium – Introduction – Features – Supported platforms Selenium Commands –
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R
Test Automation Using Selenium Presented by: Shambo Ghosh Ankit Sachan Samapti Sinhamahapatra Akshay Kotawala.
Text Selenium server 31 – October By, Vivek Singh Jeena Inderpreet Singh Ankusha Saxena Bhanupriya D.P Shubham Yadav Madhavi Aminigadda.
Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
BIT 286: Web Applications Automated Web Testing. Selenium  Selenium Is moving from being Firefox based to being more of a 'normal desktop' program that.
Arklio Studija 2007 File: / / Page 1 Automated web application testing using Selenium
Introduction of Selenium Eli Lu 2016/10/13. Outline What is selenium ? Selenium Projects Selenium Sponsors Easy to use Useful Feature & Tools Useful Links.
Test Web applications using Selenium
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Selenium and Selenium on Rails
Selenium HP Web Test Tool Training
Selenium HP Web Test Tool Training
Stable and reliable Web Automation
Selenium Web Test Tool Training Using Ruby Language
Selenium Tutorials Cheyat Training.
Web Application Development Using PHP
Selenium IDE Installation and Use.
Presentation transcript:

Testing Web Applications

Plan The presentation covers: Selenium framework Spring MVC Test framework HttpUnit framework

Selenium

What is Selenium? Selenium is a suite of tools to automate web application testing across many platforms Tests run directly in the browser Two major components: Selenium IDE Selenium WebDriver

Traditional approach for testing Release Development Feature developed Acceptance Testing Bug found! Regression Testing Regression found!

Faster feedback Write test as you go Run them as often as you can Problems are found quickly Release Regression Testing Acceptance Testing Development

Why automated tests? Manual testing is slow, tedious and error-prone Especially for regression! Either take long time or less thorough What now? Start again? Regression Testing 3 months

With automated tests Consistently thorough Fast enough to start again and again and again… Regression Testing 10 minutes

Selenium components Selenium IDE an integrated development environment for Selenium tests Selenium WebDriver a Java library write Java code, WebDriver sends commands to a browser Selenium Server (Selenium Grid) allows to run tests on different machines against different browsers in parallel

Selenium usages Browser compatibility testing Test your application to see if it works correctly on different browsers and operating systems. The same script can run on any Selenium platform. System functional testing Create regression tests to verify application functionality and user acceptance.

How to start Download and install Selenium IDE It is implemented as a Firefox extension, and allows you to record, edit, and debug tests To launch Selenium IDE in Firefox select  Tools  Selenium IDE

Selenium IDE Firefox extension Easy record and playback Not just a recorder Intelligent field selection will use IDs, names, or XPath as needed

Selenium IDE Auto-complete for all common Selenium commands Walk through tests Debug and set breakpoints Save tests as HTML, Ruby scripts, or any other format

Selenium test format Selenium saves all information in an HTML table format Each record consists of: Command – tells Selenium what to do using actions or assertions (e.g. “open”, “type”, “click”, “assertText”) Target – tells Selenium which HTML element a command refers to (e.g. textbox, header, table) Value – used for any command that might need a value of some kind (e.g. “Hello”)

Example: Selenium test

Test writing strategy 1.Start recording in Selenium IDE 2.Execute scenario on a running web application 3.Stop recording in Selenium IDE 4.Add assertions

Creating tests and test suite Create several tests in Selenium IDE Save them as e.g. \webapp\tests\discussions-suite\MyTest1.html \webapp\tests\discussions-suite\MyTest2.html Create HTML file for test suite, e.g. \webapp\tests\discussions-suite\MyTestSuite.html Music Test Suite My Test 1 My Test 2

Selenium Concepts Element Locators Specify HTML elements Patterns Used for pattern matching values Action Manipulate the state of the application Upon failure, testing stops Accessors Store results in variables Automatically generates assertions Assertion Verify that the application generate the appropriate value

Element Locators id=id Select the element with the attribute. name=name Select the first element with the attribute. identifier=id Select the element with the attribute If no match is found, select the first element dom=javascriptExpression Find an element using JavaScript traversal of the HTML DOM. DOM locators must begin with " document. " dom=document.forms['myForm'].myDropdown dom=document.images[56]

Element Locators xpath=xpathExpression Locate an element using an XPath expression. XPath locators must begin with "//". image alt text'] link=textPattern Select the link (anchor) element which contains text matching the specified pattern. link=The link text

Locator Defaults Without a locator prefix, Selenium uses: dom, for locators starting with "document." xpath, for locators starting with "//" identifier, otherwise

Actions Represent something a user would do Manipulate the state of the application Actions generally come in 2 forms: action and actionAndWait action performs the action actionAndWait assumes a server call and thus waits longer for a response open automatically waits

Command Actions open Opens the target URL click* Clicks on the target element type* Enters the value specified by the value into the specified target element select* Selects a drop-down value specified by the value in the specified target element

Command Actions selectWindow Selects a popup window using the id specified by the target. If NULL, it returns to the main window goBack Simulates user clicking back in the browser close Simulates user clicking the close button of a popup window pause Pauses the execution of a script for an amount of time in milliseconds specified in the target

Command Actions fireEvent Simulate an event to trigger the onevent handler where the target specifies the element and the value specifies the event waitForValue Waits for an input, specified by the target, to have a certain value, specified by the value (Warning: If event doesn’t occur, apply previous fix to stop running script) store Stores the value specified by the target into the variable specified by the value

Command Actions chooseCancelOnNextConfirmation Instructs Selenium to select cancel on the next JavaScript dialog raised answerOnNextPrompt Instructs Selenium to return the specified target in response to the next prompt

Assertions Allows user to verify the state of the application Three modes: assert - upon failure, test is aborted verify - upon failure, the test continues running (logging the failure) waitFor Waits timeout time for a condition’s truthiness Great for testing background Ajax behavior

Selenium IDE plugins ScreenShot on Fail Page Coverage Highlight Elements Power Debugger File Logging Stored Variables Viewer and many more…

Selenium WebDriver Selenium 2.0 has many new exciting features and improvements over Selenium 1 The primary new feature is the integration of the WebDriver API The goal is to develop an object-oriented API that provides additional support for a larger number of browsers along with improved support for modern advanced web-app testing problems

Selenium WebDriver WebDriver makes direct calls to the browser using each browser’s native support for automation Can be used equally well in a unit testing or from a plain old “main” method Java, C#, Python, Ruby, Perl, PHP bindings are provided

Selenium WebDriver Maven dependency: Now you can use WebDriver just as any normal library: it is entirely self-contained, and you do not need to start any additional processes or run any installers before using it org.seleniumhq.selenium selenium-java

Selenium WebDriver Example import org.openqa.selenium.*; public class SeleniumExample { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get(" WebElement element = driver.findElement(By.name("q")); element.sendKeys("Cheese!"); element.submit(); System.out.println("Page title is: " + driver.getTitle()); // Google's search is rendered dynamically with JavaScript. // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition () { public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith("cheese!"); } }); System.out.println("Page title is: " + driver.getTitle()); driver.quit(); }

Selenium-Grid Selenium-Grid allows to run your tests on different machines against different browsers in parallel

Selenium-Grid Reasons to use Selenium-Grid: To run your tests against multiple browsers, multiple versions of browser, and browsers running on different operating systems To reduce the time it takes for the test suite to complete a test pass

Selenium Resources Selenium Home Page Selenium dokumentācija Par Selenium latviski (var būt novecojis) ng/Selenium ng/Selenium

Spring MVC Test Framework

Spring support for testing MVC Two levels of support: Unit-testing Integration testing Unit-testing org.springframework.test.web.ModelAndViewAssert Package: org.springframework.mock.web Integration testing Support for testing client and server-side Spring MVC code through a fluent API

Spring MVC Test Framework Loads the actual Spring configuration through the TestContext framework Always uses the DispatcherServlet to process requests No need for running in a Servlet container Builds on the familiar "mock" implementations of the Servlet API

Example reference/htmlsingle/#unit-testing-spring-mvc

HttpUnit

HttpUnit framework HttpUnit is an open source software testing framework used to perform testing of web sites without the need for a web browser

Obtaining a web page response The center of HttpUnit is the WebConversation class, which takes the place of a browser talking to a single site Responsible for maintaining session context, which it does via cookies returned by the server Must create a request and ask the WebConversation for a response

Starting the conversation The response may now be manipulated either as pure text, as a DOM, or by using the various other methods WebConversation wc = new WebConversation(); WebRequest req = new GetMethodWebRequest( " WebResponse resp = wc.getResponse(req);

Examining and following links The simplest and most common form of navigation among web pages is via links HttpUnit allows users to find links by the text within them, and to use those links as new page requests WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse( " WebLink link = resp.getLinkWith("response"); link.click(); WebResponse jdoc = wc.getCurrentPage();

Using the table structure of a web page The getTables() method will return an array of the top-level tables in the page, in the order in which they appear in the document Given a table, you can ask for one of its cells, and treat the result either as text or a DOM or ask for and tables, links, or forms nested within it

Table manipulation example The following code will confirm that the first table in the page has 4 rows and 3 columns, and that there is a single link in the last cell of the first row: WebTable table = resp.getTables()[0]; assertEquals("rows", 4, table.getRowCount()); assertEquals("columns", 3,table.getColumnCount()); assertEquals("links", 1, table.getTableCell(0,2).getLinks().length );

Working with forms There are a few basic things that a tester is likely to want to do with a form The most obvious first step is to verify the controls and their default values If they are correct, the tester will generally make some changes and submit the form to see how the system responds

Testing a form WebForm form = resp.getForms()[0]; assertEquals("La Cerentolla", form.getParameterValue( "Name" )); assertEquals("Chinese", form.getParameterValue( "Food" )); assertEquals("Manayunk", form.getParameterValue( "Location" )); assertEquals("on", form.getParameterValue( "CreditCard" )); form.setParameter( "Food", "Italian" ); form.removeParameter( "CreditCard" ); form.submit();

HttpUnit Resources HttpUnit home page