KEMBAR78
FireWatir - Web Application Testing Using Ruby and Firefox | PPT
FireWatir - Web Application Testing Using Ruby & Firefox Angrez Singh Proteans Software Solutions Pvt. Ltd.
Motivation Web Applications are increasingly ubiquitous as a functionality delivery paradigm. Testing  Web Applications is important Web-Application specific test functionality in commercial test tools leaves much to be desired. …and they cost a bomb.
Problems with existing Tools Most provide record-and-replay style test automation functionality. Semantic Gap Little or no support for web application specific test functionality Vendor specific scripting languages (“Vendorscript”)
What is Ruby? Purely Object Oriented scripting language Everything is an Object as in Java Scripting language features Full Regular expression support Tight integration with OS Dynamic evaluation References http://www.rubycentral.com http://www.ruby-lang.org http://www.rubygarden.org/ruby http:// tryruby.hobix.com /
What is FireWatir? Testing Web Application using Ruby and Firefox browser Framework / Library for scripting Web application testing cases Functional testing tool for automated browser-based tests
Example Yahoo Mail
Conceptual Framework Class for Firefox Classes for each element (e.g. image, link, checkbox etc) Selection mechanism for elements (e.g. index, id, name, value etc)
Firefox Class Active methods goto() back() refresh() etc. Methods that provide current state url() title() contains_text() etc
Element Class Base class  for all Elements Provides  common methods click() enabled? exists? Selection Mechanism index, id, name, value etc
Checkbox & Radiobutton Class Summary Used to access checkbox & radiobutton Methods set, clear For e.g.: <input type=“checkbox” name=“checkbox1”> ff.checkbox(:name, “checkbox1”).clear <input type=“checkbox” name=“order” value=“order1”> <input type=“checkbox” name=“order” value=“order2”> ff.checkbox(:name, “order”, “order1”).set
SelectList Class Summary Used to select value from listbox, dropdownlist Methods option, select, select_item_in_select_list For e.g.: <select name=“selectBox”> <option value=“1”>1</option> </select> ff.select_list(:name, “selectBox”).select(“1”)
Text Field Class Summary Used for accessing text box Methods append, maxLength, set, size etc. For e.g.: <input type=“text” name=“UserName” id=“txtUserName”> ff.text_field(:name,”UserName”).set(“set value”)
Image Class Summary Use to access image Methods height, width etc. Selection   mechanism index, name, id, alt, src For e.g.: <img name=“myimage” alt=“A picture” src=“/images/mypic.jpg“> ff.image(:alt, “A picture”).height()
Example Airdeccan
Button class Summary Used to access button on page Selection mechanism caption For e.g.: <input type=“button” id=“btnSearch” name=“search” value=“Search”> ff.button(:name,”search”).click ff.button(:id,”btnSearch”).exists?
Link Class Summary Used to access link Methods innerText, src etc Properties href Selection mechanism url, text, title For e.g.: <a href=“ http:// www.google.com ” title=“Go to Google”> ff.link(:title, “Go to Google”).src ff.link(:title, “Go to Google”).link_has_image
XPath Selection Mechanism Language for addressing parts of XML document Used to navigate through elements DOM model is represented using Tree like structure XPath is used to select element in DOM Tree References http://www.w3schools.com/xpath/default.asp
Selection Mechanism Exact string match ff.text_field(:name, ”txtUserName”) Regular Expression ff.text_field(:name, /txtUserName/) XPath expression ff.text_field(:xpath, “//input[@name=‘txtUserName’]/”) ff.element_by_xpath(“//area[id=‘area1’]/”)
Example Indigo
How FireWatir interacts? Uses JSSh extension Runs at port 9997 and listens for commands Firewatir sends JavaScript commands via socket Read back the results
Advanced Concepts Handling Windows pop up Use attach method of Firefox using title Get a new Firefox instance Use this Firefox instance for accessing elements in pop up window For e.g.: newFF = ff.attach(:title, “Google”) newFF.button(:name, “Search”)
Handling Javascript Pop ups Redefines the function alert and confirm in JavaScript JSSh doesn’t get blocked For e.g.: ff.button(:name, /Sign In/).click_no_wait ff.click_jspopup_button(button)
Advanced Concepts - Example
Advantages In built XML and XPath support More compliant to standards Can support Linux, Mac platform Made to run on any client machine
References FireWatir home page http://code.google.com/p/firewatir/ JSSh home page http://croczilla.com/jssh/ Element References http://www.xulplanet.com/references/elemref/ Download XPI’s http://people.mozilla.com/~davel/jssh/
Q & A

FireWatir - Web Application Testing Using Ruby and Firefox

  • 1.
    FireWatir - WebApplication Testing Using Ruby & Firefox Angrez Singh Proteans Software Solutions Pvt. Ltd.
  • 2.
    Motivation Web Applicationsare increasingly ubiquitous as a functionality delivery paradigm. Testing Web Applications is important Web-Application specific test functionality in commercial test tools leaves much to be desired. …and they cost a bomb.
  • 3.
    Problems with existingTools Most provide record-and-replay style test automation functionality. Semantic Gap Little or no support for web application specific test functionality Vendor specific scripting languages (“Vendorscript”)
  • 4.
    What is Ruby?Purely Object Oriented scripting language Everything is an Object as in Java Scripting language features Full Regular expression support Tight integration with OS Dynamic evaluation References http://www.rubycentral.com http://www.ruby-lang.org http://www.rubygarden.org/ruby http:// tryruby.hobix.com /
  • 5.
    What is FireWatir?Testing Web Application using Ruby and Firefox browser Framework / Library for scripting Web application testing cases Functional testing tool for automated browser-based tests
  • 6.
  • 7.
    Conceptual Framework Classfor Firefox Classes for each element (e.g. image, link, checkbox etc) Selection mechanism for elements (e.g. index, id, name, value etc)
  • 8.
    Firefox Class Activemethods goto() back() refresh() etc. Methods that provide current state url() title() contains_text() etc
  • 9.
    Element Class Baseclass for all Elements Provides common methods click() enabled? exists? Selection Mechanism index, id, name, value etc
  • 10.
    Checkbox & RadiobuttonClass Summary Used to access checkbox & radiobutton Methods set, clear For e.g.: <input type=“checkbox” name=“checkbox1”> ff.checkbox(:name, “checkbox1”).clear <input type=“checkbox” name=“order” value=“order1”> <input type=“checkbox” name=“order” value=“order2”> ff.checkbox(:name, “order”, “order1”).set
  • 11.
    SelectList Class SummaryUsed to select value from listbox, dropdownlist Methods option, select, select_item_in_select_list For e.g.: <select name=“selectBox”> <option value=“1”>1</option> </select> ff.select_list(:name, “selectBox”).select(“1”)
  • 12.
    Text Field ClassSummary Used for accessing text box Methods append, maxLength, set, size etc. For e.g.: <input type=“text” name=“UserName” id=“txtUserName”> ff.text_field(:name,”UserName”).set(“set value”)
  • 13.
    Image Class SummaryUse to access image Methods height, width etc. Selection mechanism index, name, id, alt, src For e.g.: <img name=“myimage” alt=“A picture” src=“/images/mypic.jpg“> ff.image(:alt, “A picture”).height()
  • 14.
  • 15.
    Button class SummaryUsed to access button on page Selection mechanism caption For e.g.: <input type=“button” id=“btnSearch” name=“search” value=“Search”> ff.button(:name,”search”).click ff.button(:id,”btnSearch”).exists?
  • 16.
    Link Class SummaryUsed to access link Methods innerText, src etc Properties href Selection mechanism url, text, title For e.g.: <a href=“ http:// www.google.com ” title=“Go to Google”> ff.link(:title, “Go to Google”).src ff.link(:title, “Go to Google”).link_has_image
  • 17.
    XPath Selection MechanismLanguage for addressing parts of XML document Used to navigate through elements DOM model is represented using Tree like structure XPath is used to select element in DOM Tree References http://www.w3schools.com/xpath/default.asp
  • 18.
    Selection Mechanism Exactstring match ff.text_field(:name, ”txtUserName”) Regular Expression ff.text_field(:name, /txtUserName/) XPath expression ff.text_field(:xpath, “//input[@name=‘txtUserName’]/”) ff.element_by_xpath(“//area[id=‘area1’]/”)
  • 19.
  • 20.
    How FireWatir interacts?Uses JSSh extension Runs at port 9997 and listens for commands Firewatir sends JavaScript commands via socket Read back the results
  • 21.
    Advanced Concepts HandlingWindows pop up Use attach method of Firefox using title Get a new Firefox instance Use this Firefox instance for accessing elements in pop up window For e.g.: newFF = ff.attach(:title, “Google”) newFF.button(:name, “Search”)
  • 22.
    Handling Javascript Popups Redefines the function alert and confirm in JavaScript JSSh doesn’t get blocked For e.g.: ff.button(:name, /Sign In/).click_no_wait ff.click_jspopup_button(button)
  • 23.
  • 24.
    Advantages In builtXML and XPath support More compliant to standards Can support Linux, Mac platform Made to run on any client machine
  • 25.
    References FireWatir homepage http://code.google.com/p/firewatir/ JSSh home page http://croczilla.com/jssh/ Element References http://www.xulplanet.com/references/elemref/ Download XPI’s http://people.mozilla.com/~davel/jssh/
  • 26.