DOC PREVIEW
Columbia COMS W4115 - WebAppQA A Language for Testing Web Applications

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

WebAppQAA Language for Testing Web ApplicationsAdrian Frei (af2364)Ankit Malhotra (am2994)Peter Lu (yl2505)Roy H. Han (rhh2109)Submitted as a final project proposal forCOMS W4115: Programming Languages and TranslatorsTaught byProfessor Stephen A. EdwardsIntroductionWebAppQA is a language that simplifies the task of writing unit tests for a web application. It is a mix-ture between a regular scripting language like Perl or Python, unit-testing frameworks like jUnit and toolslike BadBoy. With WebAppQA, users write tests to check page format, functionality and security. Theinterpreter runs each test and produces a report.• Existence – Do all the links on a page work?• Content – Does a page match a regular expression?• Mechanics – Are links and cookies well formed?• Security – Is the page safe against cross-site scripting attacks?Usage Scenarios1. A web shop wants to automatically check a number of its product pages. Several salespeople constantlymodify these pages and sometimes links are broken and images and offers are missing.2. A company develops software in small iterations in an agile manner. This means that the productionsystem is updated frequently several times a day. Unfortunately this also means that the chance oferrors on some pages is quite high.3. Wikis and other user-defined content management systems are volatile and prone to error. Tests writtenwith WebAppQA can provide immediate feedback to the contributor before the page is released to thepublic.Language DetailsThe language is dynamically typed and runs in an interpreter. It supports loops, conditions, variables,methods with a syntax similar to Ruby. However there are no user-defined classes, iterators or blocks.Data TypesAll data types are objects and WebAppQA supports the following basic types: integers, strings, regulararrays and hash tables.More data types can be added as classes as part of libraries. At this time there is one such class: the Siteclass. Objects of this type support a number of methods to visit, navigate and test web sites.The language is dynamically typed without need for declarations. It is possible to have global variables (@prefix) and local variables (no prefix).Operators and MethodsInteger• + - * / % : Addition, Subtraction, Multiplication, Division, ModuloString• + : Concatenation with other strings and integers• \\ : Regular expressionsArray• array[i] : Array lookupHash Table• hash[’key’] : Hash table lookupSite ClassConstructor:• Site.new(url, arg, method): Creates a new object and visits the siteMethods:• visit(url, arg, method): Visits a pageAttributes:• status: The status of the page (e.g. 404 or 200)• links: All links of a page• images: All images of a page• contentType: The content type (e.g. text/html)• content: Content of the page as a string• cookies: The cookies set by the pageControl Flow and Other KeywordsThe language supports for-loops and while-loops, if and else conditions. Users defined methods using thekeyword def.The test keyword defines a test in a manner similar to the def construct.The setup keyword defines a test that is executed before all other tests.The assert keyword defines an assertion that needs to be true for the test to succeed. If an assertionevaluates to false, the execution is either interrupted or not, depending on the keyword following it: fail orwarn respectively. In either case, the error is added to the test report. The assert construct is similar to theunless construct in other languages.Following fail or warn it is possible to specify an expression that will appear in the report. Otherwise, inthe absence of any such statement, the default behavior is to print the stack trace of the failed assertion (seeReport Example).# Fail with assertion evaluates to falseassert site.status < 400 fail# Warn the user if assertion is false but continueassert site.status < 300warn "Site status must be smaller 300, got" + site.statusAnother construct is the with keyword. It is syntactic sugar that allows a developer to type less whenaccessing methods or attributes of objects. The with keyword shadows local variables and functions withthe attributes and methods of an object.object.method1()object.attribute1 = 1object.method2()can be written aswith objectmethod1()attribute1 = 1method2()endCode ExampleThe example below tests a small web shop.• Test that the home page exists• Test the login and make sure cookies are set and the user is forwarded to the welcome page• Test that the website verifies cookies and allows access to logged in users.• Test a number of offer pages and makes sure that the pages display the merchant’s logo and that alllinks on the page are working# Define a setup function (called first)setup initialize()# Global string@startURL = "www.myshop.ch"# Global hash table containing string@loginParam = {"username" => "hans", "password" => "p8ssw0rd"}end# Define a test functiontest home()# Create a new site object and visit the sitesite = Site.new(@startURL)# Make sure the page is thereassert site.status == 200 failendtest login()# Visit a site with parameters with a POST requestsite = Site.new(@startURL+"/login", @loginParam, "POST")with siteassert status == 200 fail# Only accept html contentassert contentType == "text/html" fail# Page must contain Welcome titleassert content ~= "/<title>Welcome</title>/" warn# Make sure the fields visits and id are setassert cookie["visits"] > 0 warnassert cookie["id"] != nil warnendendtest modifyCookie()# Log into the sitesite = Site.new(@startURL+"/login", @loginParam, "POST")# Make sure the id is setassert site.cookie["id"] != nil fail# Modify idsite.cookie["id"] = "deadbeefcafe"# Browse to user settingsite.visit(@startURL+"/setting")# Must be redirected to home pageassert site.status = 302 failendtest odp()# Define array with page numbers to visitpagesNr = [1,4,6,12,15,102]# Loop through all pagesfor i in 0..pagesNr.length# Construct a url with the page numberurl = @startURL+"/odp/"+pagesNr[i]site = Site.new(url)assert site.status == 200 fail# Make sure the image is there# Page number > 100 have a different imageif i < 100assert Site.new(url+"/logo.jpg").status == 200 warn "Failed at " + ielseassert Site.new(url+"/logo_big.jpg").status == 200 warn "Failed at " + iend# Call function to make sure all links are alrightlinkCheck(site)endenddef linkCheck(site)links = site.linksfor i in 0..links.lengthassert Site.new(links[i]).status == 200 warnendendReport


View Full Document

Columbia COMS W4115 - WebAppQA A Language for Testing Web Applications

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download WebAppQA A Language for Testing Web Applications
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view WebAppQA A Language for Testing Web Applications and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view WebAppQA A Language for Testing Web Applications 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?