Pages

Tuesday, 26 June 2012

OOP And UNDERSTANDING QTP SCRIPT


OBJECT ORIENTED PROGRAMMING
CLASS
A Class is a blueprint or prototype from which objects are created
it is an abstract idea of something
Class contains data members and member functions
OBJECT
Object is an instance of a class
Example
Here person is a class which contains various attributes like name,age,gender,height etc.,
Each object contains their own values for above attributes
Objects are a representation of every item found in an application
Object(eg., Buttons,TextBox) are elements with in an application
Each object has the following elements Proporties,Methods and Events
Objects are referred in code using dot notation
objectName.method
Properties
These are characteristics of the object eg., the text on a button , QTP uses this to recognize the object
Methods
These are built in functionality of the object
The VBScript code that we write(or record) actually
makes calls to the method of an object
Ex.Reporter.ReportEvent()
Here Report Event is the method of the Reporter Object
Events
These are what can do with the object. This is used by Programmers to determine what an object does in response to an action you perform. It is however unused in QTP






 UNDERSTANDING QTP SCRIPT
Windows Environment Classes and objects

1
Main Window
Window(“Window_name”)
2
Sub Window
Dialog(“Dialog_name”)
3
Edit Box
WinEdit(“EditBox Name”)
4
Combo Box
WinComboBox(“ComboBox_Name”)
5
Menu
WinMenu(“Menu”)
6
Radio Button
WinRadioButton(“Radio Button Name”)
7
Check Box
WinCheckBox(“Check Box Name”)
8
Button
WinButton(“Button Name”)


Sno
Web/Object
Class/Script
1
Browser
Browser(“Browser Name”)
2
Page
Page(“Page_Name”)
3
Frame
Frame(“Frame Name”)
4
Link
Link(“Link Name”)
5
Edit Box
WebEdit(“EditBox Name”)
6
List Box
WebList(“List Box Name”)
7
Menu
WebMenu(“Menu”)
8
Radio Button
WebRadioBUtton(“RadioButtonname”)
9
Check Box
WebCheckBox(“CheckBox Name”)
10
Button
WebBUtton(“Button Name”)


Sno
Operations
Script
1
Active Window
.Activate
2
Enter Text in Edit Box
.Set “Text”
3
Select item From List Box
.Select “Item Name”
4
Select item form the Menu
.Select “Menu_Name;Item_Name”
5
Check on/off the Radio Button
.Set “on/off”
6
Check on/off the check box
.set “on/off”
7
Press or Push Button
.click
8
Enter password in edit box
.Setsecure “Encrypted_text”
9
Close Desktop Application
.close
10
Close web Application
.closealltabs


1.Window Based
                In which window.on what object.what operation is done
Syntax
window(“Window_Name”).object(“Object_Name”).Operation/Method
2.Web Based
                In which browser.in which page.on what object.what operation is done.
Or
                in which browser.in which page.in which frame.on what object.what operation is done.
Syntax
Browser(“Browser_Name”).Page(“Page_Name”).Object(“Object_Name”).operation/Method


Sample Scripts for Windows Application
Test Scenario1
Active Window
Enter Agent Name as “admin1”
Enter Password as “mercury”
click on [ok]
Script
dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“AgentName:”).set “admin1”
Dialog(“Login”).WinEdit(“Password”).set “mercury”
Dialog(“Login”).WinButton(“ok”).click


Test Scenario2
Activate Window
Enter Employee Name as “Testtest”
Select Employee No as E001
Enter Employee Salary as 10000
Click on Submit

Script
Dialog(“Employee Details”).Activate
Dialog(“Employee Details”).WinEdit(“Employee Name’).Set “Testtest”
Dialog(“Employee Details”).WinComboBox(“Employee No”).Select “E001”
Dialog(“Employee Details”).WinEdit(“Employee Salary”).set “10000”
Dialog(Employee Details”).WinButton(“Submit”).click


Test Scenario3
Activate Window
Enter Patient Name as “ABC”
Select ward No as “11”
Select Referred Doctor as “Dr.Doctor”
Select Cough RadioButton on
Bill Check Box ON
Click on OK
Enter X-Ray cost as “200”
Enter blood Test as “300”
Enter Bed Bill as “500”
Click on “OK”
























No comments:

Post a Comment