Tuesday 9 September 2014

Password Encoder

Password Encoder:
It is built-in tool in QTP to generate encoded string for given password value

Navigation:
Ø  Start menu
Ø  All programs
Ø  QTP
Ø  Tools
Ø  Select “Password Encoder”

Ex: write script to open 5th order number record in “FR” application
Step 1: activate “FR” window
Step 2: select “Open Order…” option in “File” menu
Step 3: activate “Open Order” sub window
Step 4: set “ON” for “Order No.” check box
Step 5: enter value “5” in edit box
Step 6: click on “OK” button

Script:
Window(“FR”).Activate
Window(“FR”).WinMenu(“Menu”).select “File;Open Order…”
Window(“FR”).Dailog(“Open Order”).Activate
Window(“FR”).Dialog(“Open Order”).WinCheckbox(“Order No.”).set “ON”
Window(“FR”).Dialog(“Open Order”).WinEdit(“Edit”).set “5”
Window(“FR”).Dialog(“Open Order”).winbutton(“OK”).click


Using “With” statements:
Using “With” statement in the script we can avoid writing parent object in each step

Syntax:
With objectclass (“object name”)
                  .Method “value”
                  ------
                  -----

End With

Object Spy



Object Spy:
Using this component we can view the application object property values and operations which we can perform on that object

Navigation:
Ø  Click on “Tools” menu in QTP
Ø  Select “Object Spy”
Ø  Click on hand icon button
Ø  Click on application object which object properties and operations do you want to view

Note:
Window class object will contain Menu options
Dialog class object will not contain menu options

Ex: write script to perform login operation

Step 1: Activate Login window
Step 2: enter “Mindq” in “Agent Name:” edit box
Step 3: enter “Mercury” in “Password:” edit box
Step 4: click on “OK” button

Script:
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).set “Mindq”
Dialog(“Login”).WinEdit(“Password:”).set “Mercury”

Dialog(“Login”).WinButton(“OK”).click

VbScript in QTP Part-3


Vb Script for standard windows based applications

Objects
Object class in VB Script
Main window
Window (“window name”)
Sub window/pop-up window
Dialog(“sub window name”)
List box\combobox
WinCombobox(“list box name”)
Check box
WinCheckbox(“check box name”)
Radio button
WinRadiobutton(“Radio button name”)
Edit box\text box
WinEdit(“Edit box name”)
Push button
WinButton(“object name”)
Menu object
**WinMenu(“Menu”)

Note: application object representation in VB Script

Syntax: ObjectClass(“object logical name”)

Operations
Test object methods
Activate a window
Activate
Enter value in edit box
Set “Value”
Enter value in pwd edit box
SetSecure “encoded string”
Or Set “Value”
Select option in menu
Select “Menu name;option”
Select item in a list box
Select “items” or select (item index)
Click on push button,link, image
Click
Select option in webradiogroup
Select(“#index”)
Check box operation
Set “ON”/”OFF”
Radiobutton operation
Set

Ex: write script to perform multiply operation on “Calculator” application
Step 1: activate “Calculator” window
Step 2: click on “C” button
Step 3: click on “5” button
Step 4: click on “*” button
Step 5: Click on “9” button
Step 6: click on “=” button

Script:
Window(“Calculator”).Activate
Window(“Calculator”).WinButton(“C”).click
Window(“Calculator”).WinButton(“5”).click
Window(“Calculator”).WinButton(“*”).click
Window(“Calculator”).WinButton(“9”).click
Window(“Calculator”).WinButton(“=”).click


Ex: write script to perform submit operation in a “Sample” window
Step 1: Activate Sample window
Step 2: enter “Rajesh” in “Name:” edit box
Step 3: select “30” in “Age:” list box
Step 4: select Male radio button
Step 5: click on “submit” button

Script:
Window(“Sample”).Activate
Window(“Sample”).WinEdit(“Name:”).set “Rajesh”
Window(“Sample”).Wincombobox(“Age:”).select “30”
Window(“Sample”).WinRadiobutton(“Male”).set
Window(“Sample”).WinButton(“submit”).click


Vbscript in QTP Part-2

VB Script statement structure to perform operation on application object:

Syntax: Object hierarchy.Method “Value”

Ex:
Write VB Script to enter “Rahul” in the “Name:” edit box at “Sample” window           
Script: Window(“Sample”).winEdit(“Name:”).Set “Rahul”


In general VB Script statement contains 3 sections
1.      complete hierarchy of test object (i.e. parent to child object)
2.      operation or method or Test Object method
3.      Value or data or test data

Note: based on application environment object class can be defined

Ex: for a Edit box\Text
Standard windows based application à WinEdit
Web based application           àWebEdit
Visual basic application àVbEdit
Java environment application àJavaEdit


Vbscript in QTP - Part-1

VB Script
It is a Microsoft scripting language
VB script is case-insensitive
For comment we can use “Rem” or Single quote (‘) in front of the statement
Action Template: (Header file)
To get pre-defined components in each Action script in QTP we create and maintain Action Template

In general following are the components maintained in Action Template:
Project:
Module:
Created By:
Created On:
Test Script Description:
Referred Doc:
QTP version:
Reviewed By:
Reviewed On:

Navigation: to create Action template
  • Open Text file
  • Write required components in Action template
  • Provide comments (Rem or “’”) for each component
  • Save file with name as “ActionTemplate.mst” in QTP, data folder
  • (mstà module script template)


Note:
For a QTP we can maintain only one Action template, based on requirement we can modify information in Action template that modification will be effected only for new tests