Ruby and Watir: Your New Test Automation Tools
Total Page:16
File Type:pdf, Size:1020Kb
BIO PRESENTATION W8 10/18/2006 1:45:00 PM RUBY AND WATIR: YOUR NEW TEST AUTOMATION TOOLS Kalen Howell LexisNexis International Conference on Software Testing Analysis and Review October 16-20, 2006 Anaheim, CA USA Kalen Howell Kalen Howell is a Senior Software Test Analyst with LexisNexis® in Miamisburg, OH. For the past 4 ½ years Kalen has been part of the automation team supporting a number of applications and internal tools. Most recently Kalen has been a part of an Agile Development Team providing functional and automation test support. His technology background includes providing workstation and server support, programming in various languages and testing of web based and database applications. Kalen holds a B.S. in Information Technology from Wilberforce University and is currently working on his M.S. in Computer Science at Franklin University. Ruby and WATIR: Your New Test Automation Tool By Kalen Howell LexisNexis 1of 30 StarWest 2006 Agenda • How I discovered Ruby/Watir • An introduction to a scripting language called Ruby • An introduction to a Ruby library called WATIR • Examples of exploring Ruby/Watir features using IRB • Eclipse and other IDEs • Summary 2of 30 StarWest 2006 Discovery of Ruby/Watir • Change - From Waterfall to Agile • In search of Open Source Automation Tools • StarWest 2005 - Intro to Ruby/Watir • WATIR User’s Guide • My First Ruby/Watir test cases 3of 30 StarWest 2006 Introducing Ruby • Open source • Purely object oriented • Multithreaded • Interpreted scripting language • Highly portable 4of 30 StarWest 2006 Introducing WATIR • WATIR Library • Drives Internet Explorer via COM Objects • WATIR and IRB (Interactive Ruby Shell) • Test Execution in background 5of 30 StarWest 2006 Where to begin • WATIR User Guide: http://wtr.rubyforge.org/watir_user_guide.html – Installation – Unit Tests and Examples – Developing Test Cases – Interacting/Manipulating Web Pages – Using IRB and WATIR 6of 30 StarWest 2006 One-Click Ruby and WATIR Installer 7of 30 StarWest 2006 Prepackaged Ruby Editors • Includes Editors – Free Ride – Ruby built IDE – SCite – Text Editor 8of 30 StarWest 2006 WATIR Basics •Get IE instances ie = IE.new() ie.goto(“www.form.com”) • HTML Source is the key to using WATIR and IE to interaction with web pages <TD><INPUT id=email style="WIDTH: 200px" maxLength=60 name=email> </TD> • Set Text Field ie.text_field(:name, “email”).set(“some text”) 9of 30 StarWest 2006 A Basic Test Case 10 of 30 StarWest 2006 Results of Test Case Run 11 of 30 StarWest 2006 Filling a Web form with WATIR 12 of 30 StarWest 2006 Form Entry 13 of 30 StarWest 2006 Results of fill form test 14 of 30 StarWest 2006 Example of Refactoring test code 15 of 30 StarWest 2006 Benefits of Refactoring • Code Reuse – e.g. asserts and logging embedded in method • Simplifies Scripting – e.g. set text field – with single call and; – Assert field set correctly – Log actions to console 16 of 30 StarWest 2006 Results 17 of 30 StarWest 2006 IRB – Interactive Ruby • Console based – single line execution • Ruby playground – experiment and learn the features of Ruby • IRB and WATIR – learn how to use WATIR to drive IE • Test development – great tool to help develop test scripts 18 of 30 StarWest 2006 IRB 19 of 30 StarWest 2006 IRB 20 of 30 StarWest 2006 IRB 21 of 30 StarWest 2006 Code Examples • WATIR Example Test Case Guide: http://wtr.rubyforge.org/example_testcase.html • WATIR Unit Tests http://wtr.rubyforge.org/watir_user_guide.html 22 of 30 StarWest 2006 More Robust IDEs • Arachno Ruby • Komodo on Windows • Rad-Rails • MS Visual Studio • Eclipse via RDT (Ruby Development Tools) plug-in 23 of 30 StarWest 2006 RDT - Eclipse features • Syntax highlighting • Syntax checking • Graphical Outline • Debugging Features 24 of 30 StarWest 2006 Eclipse - Organization 25 of 30 StarWest 2006 Hierarchy view of project structure 26 of 30 StarWest 2006 Outline View of Modules and Classes 27 of 30 StarWest 2006 Code Folding 28 of 30 StarWest 2006 Summary • From Waterfall to Agile and back • I was introduced to Ruby at StarWest 2005 • Ruby – powerful and fun to learn • WATIR – employs a unique approach to driving IE • IRB – valuable utility that is easily overlooked • RDT – active project extending the power of Ruby in Eclipse • Conclusion – let’s take it to the next level 29 of 30 StarWest 2006 Contact Information Kalen R Howell Sr Sr. Software Test Analyst, Automation LexisNexis 9595 Springboro Pike Miamisburg, OH 45342 [email protected] "LexisNexis and the Knowledge Burst logo are registered trademarks of Reed Elsevier Properties Inc., used under license. Other products and services may be trademarks or registered trademarks of their respective companies. Copyright 2006 LexisNexis, a division of Reed Elsevier Inc. All rights reserved." 30 of 30 StarWest 2006.