firewatir - web application testing using ruby and firefox

Post on 13-May-2015

14.846 Views

Category:

Economy & Finance

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

FireWatir is a tool used for functional testing a web application using Ruby and Firefox browser. You can use the scripts written using WATiR that targets IE with slight changes with FireWatir

TRANSCRIPT

FireWatir - Web Application FireWatir - Web Application Testing Using Ruby & Testing Using Ruby &

FirefoxFirefox

-Angrez SinghAngrez Singh-Proteans Software Solutions Pvt. Ltd.Proteans Software Solutions Pvt. Ltd.

MotivationMotivation

Web Applications are increasingly Web Applications are increasingly ubiquitous as a functionality delivery ubiquitous as a functionality delivery paradigm.paradigm.

TestingTesting Web Applications is important Web Applications is important Web-Application specific test functionality Web-Application specific test functionality

in commercial test tools leaves much to be in commercial test tools leaves much to be desired.desired. ……and they cost a bomb.and they cost a bomb.

Problems with existing ToolsProblems with existing Tools

Most provide record-and-replay style test Most provide record-and-replay style test automation functionality.automation functionality. Semantic GapSemantic Gap Little or no support for web application Little or no support for web application

specific test functionalityspecific test functionality Vendor specific scripting languages Vendor specific scripting languages

(“Vendorscript”)(“Vendorscript”)

What is Ruby?What is Ruby? Purely Object Oriented scripting languagePurely Object Oriented scripting language Everything is an Object as in JavaEverything is an Object as in Java Scripting language featuresScripting language features

Full Regular expression supportFull Regular expression support Tight integration with OSTight integration with OS Dynamic evaluationDynamic evaluation

ReferencesReferences http://www.rubycentral.comhttp://www.rubycentral.com http://www.ruby-lang.orghttp://www.ruby-lang.org http://www.rubygarden.org/rubyhttp://www.rubygarden.org/ruby http://tryruby.hobix.com/http://tryruby.hobix.com/

What is FireWatir?What is FireWatir?

Testing Web Application using Ruby and Testing Web Application using Ruby and Firefox browserFirefox browser

Framework / Library for scripting Web Framework / Library for scripting Web application testing casesapplication testing cases

Functional testing tool for automated Functional testing tool for automated browser-based testsbrowser-based tests

Example Yahoo MailExample Yahoo Mail

Conceptual FrameworkConceptual Framework

Class for FirefoxClass for Firefox Classes for each elementClasses for each element

(e.g. image, link, checkbox etc)(e.g. image, link, checkbox etc) Selection mechanism for elementsSelection mechanism for elements

(e.g. index, id, name, value etc)(e.g. index, id, name, value etc)

Firefox ClassFirefox Class

Active methodsActive methods goto()goto() back()back() refresh() etc.refresh() etc.

Methods that provide current stateMethods that provide current state url()url() title()title() contains_text() etccontains_text() etc

Element ClassElement Class

Base classBase class for all Elements for all Elements Provides Provides common methodscommon methods

click()click() enabled?enabled? exists?exists?

Selection MechanismSelection Mechanism index, id, name, value etcindex, id, name, value etc

Checkbox & Radiobutton ClassCheckbox & Radiobutton Class

SummarySummary Used to access checkbox & radiobuttonUsed to access checkbox & radiobutton

MethodsMethods• set, clearset, clear

For e.g.:For e.g.:<input type=“checkbox” name=“checkbox1”><input type=“checkbox” name=“checkbox1”>

ff.checkbox(:name, “checkbox1”).clearff.checkbox(:name, “checkbox1”).clear

<input type=“checkbox” name=“order” value=“order1”><input type=“checkbox” name=“order” value=“order1”><input type=“checkbox” name=“order” value=“order2”><input type=“checkbox” name=“order” value=“order2”>

ff.checkbox(:name, “order”, “order1”).setff.checkbox(:name, “order”, “order1”).set

SelectList ClassSelectList Class

SummarySummary Used to select value from listbox, Used to select value from listbox,

dropdownlistdropdownlist MethodsMethods

option, select, select_item_in_select_listoption, select, select_item_in_select_list

For e.g.:For e.g.:

<select name=“selectBox”><select name=“selectBox”>

<option value=“1”>1</option><option value=“1”>1</option>

</select></select>

ff.select_list(:name, “selectBox”).select(“1”)ff.select_list(:name, “selectBox”).select(“1”)

Text Field ClassText Field Class

SummarySummary Used for accessing text boxUsed for accessing text box

MethodsMethods append, maxLength, set, size etc.append, maxLength, set, size etc.

For e.g.:For e.g.:

<input type=“text” name=“UserName” id=“txtUserName”><input type=“text” name=“UserName” id=“txtUserName”>

ff.text_field(:name,”UserName”).set(“set value”)ff.text_field(:name,”UserName”).set(“set value”)

Image ClassImage Class SummarySummary

Use to access imageUse to access image MethodsMethods

height, width etc.height, width etc. SelectionSelection mechanismmechanism

index, name, id, alt, srcindex, name, id, alt, src

For e.g.:For e.g.:<img name=“myimage” alt=“A picture” <img name=“myimage” alt=“A picture” src=“/images/mypic.jpg“>src=“/images/mypic.jpg“>

ff.image(:alt, “A picture”).height()ff.image(:alt, “A picture”).height()

Example AirdeccanExample Airdeccan

Button classButton class

SummarySummary Used to access button on pageUsed to access button on page

Selection mechanismSelection mechanism captioncaption

For e.g.:For e.g.:

<input type=“button” id=“btnSearch” name=“search” <input type=“button” id=“btnSearch” name=“search” value=“Search”>value=“Search”>

ff.button(:name,”search”).clickff.button(:name,”search”).click

ff.button(:id,”btnSearch”).exists?ff.button(:id,”btnSearch”).exists?

Link ClassLink Class SummarySummary

Used to access linkUsed to access link

MethodsMethods innerText, src etcinnerText, src etc

PropertiesProperties hrefhref

Selection mechanismSelection mechanism url, text, titleurl, text, title

For e.g.:For e.g.:<a href=“http://www.google.com” title=“Go to Google”><a href=“http://www.google.com” title=“Go to Google”>ff.link(:title, “Go to Google”).srcff.link(:title, “Go to Google”).srcff.link(:title, “Go to Google”).link_has_imageff.link(:title, “Go to Google”).link_has_image

XPath Selection MechanismXPath Selection Mechanism

Language for addressing parts of XML Language for addressing parts of XML documentdocument

Used to navigate through elementsUsed to navigate through elements DOM model is represented using Tree like DOM model is represented using Tree like

structurestructure XPath is used to select element in DOM XPath is used to select element in DOM

TreeTree ReferencesReferences

http://www.w3schools.com/xpath/default.asphttp://www.w3schools.com/xpath/default.asp

Selection MechanismSelection Mechanism

Exact string matchExact string match ff.text_field(:name, ”txtUserName”)ff.text_field(:name, ”txtUserName”)

Regular ExpressionRegular Expression ff.text_field(:name, /txtUserName/)ff.text_field(:name, /txtUserName/)

XPath expressionXPath expression ff.text_field(:xpath, ff.text_field(:xpath, “//input[@name=‘txtUserName’]/”)“//input[@name=‘txtUserName’]/”)

ff.element_by_xpath(“//area[id=‘area1’]/”)ff.element_by_xpath(“//area[id=‘area1’]/”)

Example IndigoExample Indigo

How FireWatir interacts?How FireWatir interacts?

Uses JSSh extensionUses JSSh extension Runs at port 9997 and listens for Runs at port 9997 and listens for

commandscommands Firewatir sends JavaScript commands via Firewatir sends JavaScript commands via

socketsocket Read back the resultsRead back the results

Advanced ConceptsAdvanced Concepts

Handling Windows pop upHandling Windows pop up Use attach method of Firefox using titleUse attach method of Firefox using title Get a new Firefox instanceGet a new Firefox instance Use this Firefox instance for accessing Use this Firefox instance for accessing

elements in pop up windowelements in pop up window

For e.g.:For e.g.:

newFF = ff.attach(:title, “Google”)newFF = ff.attach(:title, “Google”)

newFF.button(:name, “Search”)newFF.button(:name, “Search”)

Handling Javascript Pop upsHandling Javascript Pop ups

Redefines the function alert and confirm in Redefines the function alert and confirm in JavaScriptJavaScript

JSSh doesn’t get blockedJSSh doesn’t get blocked

For e.g.:For e.g.:

ff.button(:name, /Sign In/).click_no_waitff.button(:name, /Sign In/).click_no_wait

ff.click_jspopup_button(button)ff.click_jspopup_button(button)

Advanced Concepts - ExampleAdvanced Concepts - Example

AdvantagesAdvantages

In built XML and XPath supportIn built XML and XPath support More compliant to standardsMore compliant to standards Can support Linux, Mac platformCan support Linux, Mac platform Made to run on any client machineMade to run on any client machine

ReferencesReferences

FireWatir home pageFireWatir home page http://code.google.com/p/firewatir/http://code.google.com/p/firewatir/

JSSh home pageJSSh home page http://croczilla.com/jssh/http://croczilla.com/jssh/

Element ReferencesElement References http://www.xulplanet.com/references/elemref/http://www.xulplanet.com/references/elemref/

Download XPI’sDownload XPI’s http://people.mozilla.com/~davel/jssh/http://people.mozilla.com/~davel/jssh/

Q & AQ & A

top related