Tuesday, 9 September 2014

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


0 comments:

Post a Comment