Pages

Saturday, November 27, 2010

Recording a simple script on Dialog Login with various options to generate the password

Step1 : Open QT click o Record ,select "Window Applications" in "Record and Run Settings" and click on "OK"

Step 2 : click on Flight Application ,Enter Username,Password and click on "OK".It generates the script as follows

SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "agent"
Dialog("Login").WinEdit("Password:").SetSecure "4cf162a450b1f22358a30a702947fa15c2d4fe74"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close


Step 3 : Click on "RUN" 

To get Encryted  password 

There are 2 other ways other than recording 
1.Using Crypt.Encrypt method
2.Using the tool Password Encoder

Using the Crypt method the script will be as follows

SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "agent"
pwd = crypt.Encrypt("mercury")
Dialog("Login").WinEdit("Password:").SetSecure pwd
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close



The steps for the option Password Encoder

Step a : go to start-->Programs-->Quick Test Professional-->Tools-->Password Encoder-->Write the password as Mercury in "password" edit box
Step b : Click on Generate ,It will generate the password
Step c: Copy and paste it in the script in the required location


Regular Expression which works for any webpage to count total links present on the page

Dim oLink,Links, TotLinks
Set oLink=Description.Create
oLink("micclass").value="Link"
Set Links=Browser("title:=.*").page("title:=.*").ChildObjects(oLink)
TotLinks=Links.count
Reporter.ReportEvent 2,"Res","Total Links are: "&TotLinks

Random Numbers in Flight Application

STEP1: Record a session on Flight Reservation for insert new order.the  recorded script is as follows


Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121210"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Zurich"
Window("Flight Reservation").WinComboBox("Fly To:").Select "London"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "swarupa"
Window("Flight Reservation").WinButton("Insert Order").Click

Step 2: Apply the Concept of Random number to Fly_From and Fly_To as follows


Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation").ActiveX("MaskEdBox").Type "121210"
Window("Flight Reservation").WinComboBox("Fly From:").Select RandomNumber.Value(0,9)
Window("Flight Reservation").WinComboBox("Fly To:").Select Randomnumber.Value(0,9)
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "sweeya"
Window("Flight Reservation").WinButton("Insert Order").Click

Note : as there are 10 values in the combo-box  i have given the values for Random numbers as 0 for lowest interval and 9 for the highest value

Step 3: Now RUN the test you can see the application takes Random values for Fly_From and Fly_To every time we execute the script