Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products testing.
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products testing. Presented by Sveatoslav Circel, Senior QA @Gametech LLC. mailto:firstname.lastname@example.org
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE productsCoverage:*Introduction and advantages.*Getting started with Ruby and Watir.*Basic Watir elements and functions.*Script structure and validation points.*SVN Repository for automation scripts.*Running the tests (BOUI + Frontend).*Running the tests in batch.*Analyzing the logs/results.*Debugging with IRB.
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Advantages of Test AutomationReliable: Tests perform precisely the same operations each time they are run, thereby eliminating human errorRepeatable: You can test how the software reacts under repeated execution of the same operations.Programmable: You can program sophisticated tests that bring out hidden information from the application.Comprehensive: You can build a suite of tests that covers every feature in your application.Reusable: You can reuse tests on different versions of an application, even if the user interface changes.Better Quality Software: Because you can run more tests in less time with fewer resourcesFast: Automated Tools run tests significantly faster than human users.Cost Reduction: As the number of resources for regression test are reduced.
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE productsThe Ruby Language Dynamic; Easy to understand syntax; Easy to use interpreter; Object oriented; Cross-platform; Powerful class libraries; Massive online support communities base; More info on ruby: http://www.youtube.com/watch?v=fYIEV_6xhck
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products What is Watir? A free, open-source functional testing tool for web applications. It is a Ruby library which drives almost any browser the same way people do, clicks links, fills in forms, and presses buttons. Watir also checks results, such as whether expected text appears on the page or not. Because it’s build on Ruby, you have the power to connect to databases, read data files, save screenshots, manipulate the file system, export to CSV and XML, structure your code into reusable libraries.
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Why use Watir? Free Powerful Simple (easy to use and learn) Excellent Support It uses Ruby, a full-featured object oriented scripting language Broad usage in high level client base.
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products What the Users say…− “…WATIR is by far the most complete web testing framework out here--that doesnt cost an arm and a leg. And this forum is the most active and well supported that I have seen. You can post a question and is just a short period of time get someone (most of the time the architects of the framework!) who will steer you in the right direct, give you a work around to get over any roadblocks, or add it to the framework if it doesnt currently exist. That is the reason I switched and tell everyone interest (and those not) that Ruby is the way to go! Save your money, get WATIR!” − “Ruby is an awesome language and Watir is just too cool. It does things that other companies (ie. IBM/Rational, Mercury, Segue, etc) charge thousands and thousands of dollars a seat for. Anyway, now that Im gettin the hang of Ruby and Watir, Im starting to automate everything I do on the web. Even the simple things like logging in to web sites, searches, you name it.” (source: www.watir.com)
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products How do we get started?Install Ruby: Use the www.rubyinstaller.org/downloads/ link, download and install latest version.Install rubygems update(http://rubygems.org/) with the following ruby command prompt (Start -> Programs -> Ruby 1.9.3 -> Start Command Prompt with Ruby): gem update --systemDownload DevKit, that makes it easy to build and use native C/C++ extensions. Wed need that for Opera and Chrome support. Follow the install instructions in: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit Install ChromeDriver. For Google Chrome, additionally, wed need to install the library. Go to http://code.google.com/p/chromedriver/downloads/list and download latest version. Unzip the file and put it in any folder that is in your PATH. (For example C:Ruby1.9.3Bin)Install Watir-Webdriver gem in ruby command prompt (Start -> Programs -> Ruby 1.9.3 -> Start Command Prompt with Ruby): “gem install watir- webdriver”Read the Users Guide, documentation, examples and tests for reference.
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Some Helpful Tools…Editors:• Notepad++ (A good light-weight editor supporting Ruby code orthography and stylistics)Tips for finding/accessing HTML elements:• IE Developer Tool bar (Lets you explore the HTML elements behind the visible elements on a web page by clicking on the elements• FireBug (Excellent FireFox extension for identifying HTML elements while writing scripts.)• WATIR::SupportsSubElements (Watir API for accessing html elements)
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Navigating the Browser# Always Loading the Rubygems and Watir/Webdriver libraries at the top of each scriptrequire rubygemsrequire watir-webdriver#Start a browser and navigate to a given URLbrowser = Watir::Browser.start(http://conancasino.com)#or.. open a separated instance of any of supported web-browsers:browser = Watir::Browser.new :firefoxbrowser = Watir::Browser.new :iebrowser = Watir::Browser.new :chrome (need to be pre-configured)browser = Watir::Browser.new :opera (need to be pre-configured)browser = Watir::Browser.new :safari (only for Mac OS X)(note: in my scripts I set a variable called b instead of browser; thus in most of the scripts it would look like: b = Watir::Browser.new :chrome)#Navigate to a different URLbrowser.goto("http://www.conancasino.com/")#Close IE.browser.close
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Finding <HTML> ElementsTextBox browser.text_field(:name, “name”).set “Value”Button browser.button(:text, /text/).clickDropDownList browser.select_list(:id, “id”).set “Value”CheckBox browser.checkbox(:class, “class_id”).clickRadioButton browser.radio(:class, “class_id”).clickHyperLink browser.link(:href, “URL”).clickForm browser.form(:name, “name”).set “Value”Frame browser.frame(:id, “frame1”).useAnd many, many more (div, label, image, etc…)…
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE productsBest Practices for Watir Locators – The Locator Tree of Life
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Flash Automation require win32ole autoit = WIN32OLE.new("AutoItX3.Control") autoit.WinActivate("Chrome","Conan Casino") autoit.MouseClick("left",950,500,1)I have recorded a small automated test run session for your convenience:http://dl.dropbox.com/u/485410/Presentation/Flash_Automation_with_Ruby_Watir_and_Autoit.mp4
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Running the scriptsScripts are being executed using Ruby command promt. Openruby command prompt (Start -> Programs -> Ruby 1.9.3 ->Start Command Prompt with Ruby); CD to directory withscripts; Run using the following command:ruby name_of_the_script.rbI have recorded a small automated test run session for your convenience:http://dl.dropbox.com/u/485410/Presentation/Running_a_script_and_analyzing_results.mp4
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Running the scripts in batchIn order to be able to run the scripts in batch, we created a simple*.BAT file, in which included the set of all available scripts,including both error and positive output redirection to txt files:ruby FR001-Account-Creation-chrome.rb > FR001-Account-Creation-chrome.txt 2>&1…Open ruby command prompt (Start -> Programs -> Ruby 1.9.3 ->Start Command Prompt with Ruby); CD to directory with scripts;C:automationqa>Frontend.batI have recorded a small automated test run session for your convenience:http://dl.dropbox.com/u/485410/Presentation/Analyzing_the_batch_results.mp4
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Analyzing the resultsThe scripts are saving 3 type of results:1. Export scenario output as Passed/Failed in the test_results.csv, includingthe name of the test and time of execution.2. Save screenshots of the web pages in the same dirrectory where thescript is located.3. Print the output to the user within the windows ruby shell - cmd. (canalso be redirected as output to a different file using > file.txt for furtheranalysis)I have recorded a small automated test run session for your convenience:http://dl.dropbox.com/u/485410/Presentation/Analyzing_the_batch_results.mp4http://dl.dropbox.com/u/485410/Presentation/Running_a_script_and_analyzing_results.mp4
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Local SVN RepositoryThe scripts are located in our SVN which is being permanently updated and renewed by new commits of improved scripts. The read-write permissions are granted only to QA team (including myself, Nick, Dmitrii and Vitalii). Read permissions – accessible to anyone within the company.To access to SVN you have 2 ways 1. In browser go to link: http://192.168.10.10/svn/gs1/trunk/tests/automatization/qa2. Download the "TortoiseSVN" (http://tortoisesvn.net/downloads.html) and synchronize it with your local folder.Note: Do not run the scripts from SVN, copy to local.
Basic Script structure and validation points. FR006-Frontend-FAQ-Elements-Conan-Club-VIP.rb
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Debugging with IRB• IRB = Interactive Ruby Shell; Command line-like interface that allows immediate running of Ruby script. Great for debugging one line at a time, rather then having to run through an entire script. Great for testing single lines
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products Plans for the future Practice test-driven development. Defects can be described using a test script that reproduces the defect. (attaching the script to Jira) Automation training the manual testers Creating a VM with ruby & watir pre-setup and ready to go. VirtualBox implementation and support of all OSes and browsers for test automation (Win, *nix and Mac OS X systems) Continuous integration with JENKINS:http://watirmelon.com/2011/08/29/running-your-watir-webdriver-tests-in-the-cloud-for-free/http://blog.houseofsoft.org/2011/04/05/automate-your-feature-tests/4/http://martinfowler.com/articles/continuousIntegration.html
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE productsQuestions ?…