Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
qtApp.Open "Q:\QTP_Files\AUTs\xxxx\xxx\xxx\TestScript", True ' Open the test in read-only mode
' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Run ' Run the test
WScript.StdOut.Write "Status is:" & qtTest.LastRunResults.Status ' Check the results of the test run
qtTest.Close ' Close the test
Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
QTP/UFT,QualityCenter,QC,ALM,ManualTesting,Ruby on rails,WATIR Framework,Ruby,VBScripting,Selenium,QCOpenTestArchitecture,ExcelReports,Certifications,LoadRunner,InterviewQuestions,BPT,API's,VSTS,QTP Trainings, Test Complete,Ranorex,Jenkins
Search This Blog
Saturday, January 1, 2011
Saturday, October 9, 2010
How to install Ruby on Rails for web testing automation
Overview
This document outlines the installation of the Test Automation Ruby on Rails application for web testing automation. It has been tested on Windows XP and Server 2003, but should work with Vista, 7, and Server 2008. Administrative user permissions are preferable for this install. The below tables provide reference to sources of software needed throughout the install.
Required Software(exact versions below are Required for proper installation): | |
Software | URL |
Ruby for windows: ruby186-26.exe | |
rubygems-1.3.7.zip | |
MySql Database: mysql-essential-5.0.83-win32.msi (or mysql-noinstall-5.0.83-win32.zip if admin access not available) | |
mysql-gui-tools-5.0-r17-win32.msi | |
dbi-dbd-mysql.zip | Provided |
jruby-bin-1.4.0.zip | Provided |
browser.rb | Provided |
deploy_n.n.n[_xxx].zip | Provided |
vendor_n.n.n.zip | Provided |
Additional Tools(optional) | |
Tool | URL |
7-zip compression tool (7z465.msi) | |
eclipse-SDK-3.5.2-win32.zip | |
UnxUtils.zip |
Step-by-Step Install Instructions(follow in order):
Install Ruby 1.8.6.26
1. Run the ruby one-click self installer(it should run from above link): ruby186-26.exe
2. After ruby is installed, update rubygems:
Issue following commands from command line:
set http_proxy=http://proxy.xxxxx.com:80
gem update --system
3. Install the following gems:
gem install mongrel
gem install roo
gem install spreadsheet
gem install google-spreadsheet-ruby
gem install mysql
gem install watir
gem install rubyzip
All other required gems are installed in the applications vendor/ directory.
Install MySQL 5.0.83:
Note: MySQL 5.1.x versions are known to have problems playing nicely with Rails 2.3.x
If you have admin access under windows use the msi essentials(mysql-essential-5.0.83-win32.msi),
otherwise use the 32 bit zip file (mysql-noinstall-5.0.83-win32.zip).
If using the MSI file, choose complete installation for multi-use.
1. Set the root password to ‘waftt’
2. Set the checkbox so that the ../bin directory will be added to path.
3. Install as service!
4. Set port to 9999 (default is 3306 but that gets Windows confused...)
If using the zip file, unzip to Program Files/ using paths in the zip file.
1. Add the ../bin directory to path
2. Copy my.ini to the MySQL root path.
3. Do not start mysql yet!
Install MySQL 5.0 GUI tools:
1. Run the mysql-gui-tools-5.0-r17-win32.msi self installer (it should run from above link).
Install waft:
1. Create a waftt/ directory under program files and change to that directory.
2. Unzip deploy_n.n.n[_xxx].zip using paths
3. Unzip vendor_n.n.n.zip using paths.
(WHERE: n.n.n is version number AND xxx is (optional) project acronym)
Register AutoItX3.dll:
1. Open command window
2. Change to \Program Files\waftt\vendor\gems\watir-1.6.5\lib\watir
3. Execute 'regsvr32 AutoItX3.dll'
Install Test Automation database:
Open MySQL Administrator and log on as root using the password you created above.
If you have installed using the .zip file, start the service
1. Edit /program_files/waftt/config/database.yml to set username to root and password to ‘waftt’ for all three environments (development, test, production).
2. Open command window to /Program files/waftt
3. Run the following commands:
rake db:create:all
rake db:schema:load
Open MySQL query browser as root:
1. Run command: select * from schema_migrations
2. Delete the following row: 20100416225210
3. Click Edit at bottom
4. Right click on the row
5. Select Delete row(s)
6. Click Apply Changes
Run In command window:
rake db:migrate
A rake error saying something about 'reenable' is ok. Keep going.
rake db:seed:loaddemo
In MySQL Administrator
1. Refresh catalog view
2. In User Administration create user waftt with password waftt
3. Assign waftt all schema privileges for schemae waftt, waftt_test, and waftt_development
4. Apply changes
Restart the MySQL service (Service Control)
Edit /program_files/waftt/config/database.yml again to reset username to ‘waftt’ and password to ‘waftt’ for all three environments (development, test, production).
If the service won't restart check the xxx.err log(s) in the data directory.
If it is complaining about 3306 already in use, reboot and try again.
If the problem persists edit the my.ini file to use 9999 instead of 3306.
If it is complaining about the InnoDB log file size, edit my.ini to change to 5M.
Starting MySQL when not installed as service
If you are using the zip installation, the mysql driver will not start automatically.
You can do one of two things:
1. Execute the wafttmysqlserver.cmd script ONCE whenever you reboot. The window will disappear but the process is still running.
OR
2. From a cmd.exe window execute 'mysql-nt --install' to run as a service if you have admin rights.
If you have problems, look in the ../data directory for files ending in .err.
They will contain helpful information.
Refer to Install Test Automation database above for additional information.
Load Simulation setup
1. Unzip jruby-1.4.0.zip to your C drive under \Program Files
2. Add c:\Program Files\jruby-1.4.0\bin to your path (after your ruby\bin path entry)
3. In command window
4. Now install celerity: (do the set proxy if you haven't done so in this window)
5. Run following command:
jruby -S gem install celerity -v 0.7.7
6. Unzip dbi-dbd-mysql.zip (to C:\ or to a temporary directory)
7. Change to each folder ( .\dbd-mysql-0.4.4 and .\dbi-0.4.3 )
8. Execute commands below in each folder:
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
9. Copy ./doc/browser.rb file to C:\Program Files\jruby-1.4.0\lib\ruby\gems\1.8\gems\celerity-0.7.7\lib\celerity\
Start Test Automation:
1. Navigate to Program Files/waftt/ (either in command window or windows explorer)
2. Execute wafttservices.cmd, this will start the services Test Automation needs in order to run. You should now have the following windows running minimized:
rails server
rake jobs:work 1
ring server
regression server 1
load server 1
They should remain running.
Use Test Automation:
1. Open firefox ( IE will be forced closed by the running scripts as a workaround for some IE and Watir issues not yet resolved.)
2. Go to http:/localhost:3000. You should see a login page. If you do not already have a registered id you can log in as tester/tester. If the rails server window won't stay open, reboot and try again, or close all the remaining waftt windows and run localwafttservices.cmd. Then use http:/localhost:9191
SEE THE WAFTT USER GUIDE FOR ACCOUNT SETUP AND WAFTT USER INSTRUCTIONS
Labels:
WATIR
Validating Test Results in WATIR
How do we tell whether the test passed or failed? It is good practice to use a verification point in your test case.
To create a valid test case, we need to use some sort of validation. It isn't enough to have a sequence of events without validation in a test script. Watir can check the state of objects in the Internet Explorer DOM, and can check to see if a page contains the objects that are expected for the test to pass.
A simple verification point is to use the Watir method contains_text.
In our test, imagine we have gone through a sequence of steps to reach the desired point. This is a web page that contains the following text:
Reached test verification point.
Our test will pass if this is what is displayed on the page at our verification point.
Watir code to check that the text exists on the web page is contains_text method:
ie.contains_text("Reached test verification point.")
We will need to add some scripting code to validate that this occurred. Scripting code to let us know whether the test passed or not:
if ie.contains_text("Reached test verification point.")
puts: "Test passed. Page contains the text: Reached test verification point."
else
puts: "Test failed! Page didn't contain text: Reached test verification point."
End
This is what the scripting code above does:
- checks if there is text Reached test verification point.
- if true, print our passing message to the screen
- if false, print our failure message to the screen
- end our if block
Labels:
WATIR
Some of the common HTML elements and how to handle them using Watir
Buttons
In web applications, we generally submit information we have entered or selected in the web page by clicking links, buttons and images, or by hitting Enter/Return on our keyboard.
Watir clicks buttons on a web page by looking at the attributes available in the
HTML Buttons
What you see in the web browser:
This is the tag in the HTML source:
"button" id="one" name="clickme" value="Click Me">
id Attribute
This is the Watir code you need to click a button using the id attribute:
ie.button(:id, "one").click
name Attribute
This is the Watir code you need to click a button using the name attribute:
ie.button(:name, "clickme").click
value Attribute
This is the Watir code you need to click a button using the value attribute:
ie.button(:value, "Click Me").click
Image Buttons
tag looks like an image, but acts like a button. Like HTML buttons it can be accessed by id, name and value attributes. Image buttons can also be accessed by their src attribute.
src Attribute
What you see in the web browser:
This is the tag in the HTML source:
"image" src="images/doit.gif">
This is the Watir code you need to click a button with an image using the src attribute as a regular expression:
ie.button(:src, /doit/).click
In this case we're looking for a button with doit as part of the src attribute.
Checkboxes
Watir sets or clears checkboxes by looking at the attributes available in the HTML tag. Common attributes are id and name.
What you see in the web browser:
Check Me:
This is the tag in the HTML source:
Check Me:"checkbox" id="one" name="checkme">
id Attribute
Watir code to set a checkbox using the id attribute:
ie.checkbox(:id, "one").set
Watir code to clear a checkbox using the id attribute:
ie.checkbox(:id, "one").clear
name Attribute
Watir code to set a checkbox using the name attribute:
ie.checkbox(:name, "checkme").set
Watir code to clear a checkbox using the name attribute:
ie.checkbox(:name, "checkme").clear
Links
You can use Watir to click links in a variety of ways. Watir can click links by looking at the link text you see in the browser or by looking at the attributes available in the HTML tag. Common attributes are id, name and href. For
"http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe
id Attribute
Watir code to click a link using the id attribute:
ie.link(:id, "one").click
name Attribute
Watir code to click a link using the name attribute:
ie.link(:name, "book").click
Text
Watir code to click a link using link's text:
ie.link(:text, "Pickaxe").click
href Attribute
Watir code to click a link using the href attribute:
ie.link(:href, "http://pragmaticprogrammer.com/titles/ruby/").click
Radio Buttons
Watir sets or clears radio list items by looking at the attributes available in the HTML tag. Common attributes are id and name.
What you see in the web browser:
Click Me:
This is the tag in the HTML source:
"radio" name="clickme" id="one">
id Attribute
Watir code to set a radio list item using the and id attribute:
ie.radio(:id, "one").set
Watir code to clear a radio list item using the id attribute:
ie.radio(:id, "one").clear
name Attribute
Watir code to set a radio list item using the name attribute:
ie.radio(:name, "clickme").set
Watir code to clear a radio list item using the name attribute:
ie.radio(:name, "clickme").clear
Selection Boxes
Watir sets or clears an item in a selection box (or dropdown box) by looking at the attributes available in the
id Attribute
Watir code to set a select box item using the id attribute:
ie.select_list(:id, "one").set("is fun")
name Attribute
Watir code to set a select box item using the name attribute:
ie.select_list(:name, "selectme").set("is fun")
Selection Box Methods
Watir code to clear a select box item using the id attribute:
ie.select_list(:id, "one").clearSelection
Watir code to get the contents of a select list:
contents = ie.select_list(:id, "one").getAllContents
NOTE: contents will be an array
Select Multiple
Some select lists can have multiple selections instead of just one. If multiple items can be selected in select box, Watir can set or clear an item.
What you see in the web browser:
This is the tag in the HTML source:
You can set individual options using successive _set_s and you can clear everything that is selected with the clearSelection method. The following code would select every option in the select list and then clear everything.
ie.select_list(:id, 'one').set('Web Testing')
ie.select_list(:id, 'one').set('in Ruby')
ie.select_list(:id, 'one').set('is fun')
ie.select_list(:id, 'one').clearSelection
Labels:
WATIR
Subscribe to:
Posts (Atom)