Wednesday, 2 March 2011


QTP  FUNCTIONS AND METHODS


Important Methods:
Syntax for Methods Displays while recording: 
Window based Syntax: 
Window ("Window Name").Object("Object Name").Opera / method

Web based Syntax:
Browser ("Browser Name").Page ("Page Name"). Opera / method

Functions List:
InputBox() - Accept the Input from the keyboard 
MsgBox() - Displays the Output on the Separate Small Window (Like Popup)
Print() - Displays the Output on the Separate Window with File Menu when user Print Statement.

General Important Methods List in QTP:
Encrypt
GetVisibleText
GetROProperty
GetTOProperty
Reporeter.RepoerterEvent
ReporterPath

DataTable Methods:
DataTable.Import
DataTable.ImportSheet
DataTable.Export
DataTable.ExportSheet
DataTable.Add
DataTable.Delete
DataTable.Find
DataTable.Remove
DataTable.RemoveAll()





Functions


Input Function / Input Statement:           InputBox
Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)
Output Function / Output Function:     
1)Detailed Explanation for MsgBox
Ex1. Display the Exclamatory Mark with Ok and Cancel Button by using the MsgBox  Output function / Output Statement.
Dim MyVar
MyVar = MsgBox ("Hello World!", 65, "MsgBox Example")
   ' MyVar contains either 1 or 2, depending on which button is clicked.

Output:


Ex2.
Dim MyVar
MyVar = MsgBox ("Hello World!", 57, "MsgBox Example")

Output:


Note:  Observing the Symbols in MsgBox Displays meaning fully.
2) Print()
For i=1 to 5 step 1
         Print(i)
Next

Output: A separate window open for display the numbers when use the Print Statement.


General Methods

Crypt Object:  It is used to encrypt the strings.  For this use the Encrypt method which takes string (string to encrypt) as its parameter.
Dim Pass
Pass = InputBox("enter the encrpt word: ")
msgBox Crypt_Pass(pass)
Function Crypt_Pass(epas)
Crypt_Pass = Crypt.Encrypt(epas)
End Function



1. GetVisibleText            à  To Capture text of object. 
Windows based Syntax:
X = Window(“Sample”).WinEdit(“Name”).GetVisiblertext

2. GetROProperty            à  To Capture Runtime object property value into variable.
Windows based Syntax:
X = Window(“Sample”).WinButton(“Name”).GetROProperty

3. GetTOProperty            à  To Capture TestObject Property value into variable.
Windows based Syntax:
X = Window(“Sample”).WinButton(“Name”).GetTOProperty

4. Reporeter.RepoerterEvent    à  We can use this method to report an event to the test results.
Reporter.ReportEvent Status, “Step”, “Details”

Status:   0 à micPass, 1à micFail, 2àmicDone, 3àmicWarning
5. ReporterPath:              à To get current test results folder path.
msgbox Reporter.ReportPath

Data Table Methods
1.  DataTable.AddSheet:
Before Add Sheet Data Table Look Like:



DataTable.AddSheet "RTResultSheet"
Run>
Output: After Add the Sheet to the Run-Time Data Table Output is Look Like
Navigation: 1. Click on Result Icon on the Tool Bar.
                      2. Click on Run-Time Data Table à RTResultSheet added


2.  DataTable.Delete
Before Add Sheet Data Table Look Like:



Step 1:
DataTable.AddSheet "RTResultSheet1"
DataTable.AddSheet "RTResultSheet2"
Run>
Output: After Add the Sheet to the Run-Time Data Table Output is Look Like
Navigation: 1. Click on Result Icon on the Tool Bar.
                      2. Click on Run-Time Data Table à RTResultSheet1, RTResultSheet2 added.
Output:





Step 2: add the script to the above script in Expert View
DataTable.AddSheet "RTResultSheet1"
DataTable.AddSheet "RTResultSheet2"
DataTable.DeleteSheet "RTResultSheet1"
Run>
Output: After Add the Sheet to the Run-Time Data Table Output is Look Like
Navigation: 1. Click on Result Icon on the Tool Bar.
                      2. Click on Run-Time Data Table à show only RTResultSheet2 added, shows only RTResultSheet1 in the run Time Data Table.
Output:











1) Activate Method à It activates dialog boxes / Windows
Syntax: Object hierarchy. Activate
Ex:
Dialog(“Login”).Activate
Window(“Flight Reservation”).Activate

2) Click Method à It clicks on an object (Buttons)
Syntax: Object hierarchy. Click
Ex:
Dialog(“Login”).Winbutton(“ok”).click

3) Close Method à It closes the window,Dialog box, Browser window etc.
Syntax: Object hierarchy. Close
Ex:
Window(“Flight Reservation”).Close
Browser(“Browser”).Close

4) Set Method à It can be used in three ways.
a) For setting the value of an edit box
Syntax: Object Hierarchy. SET “Value”
Ex: Dialog (“Login”).WinEdit(“Agent Name”).Set “asdf”
b) Selecting a Radio Button
Syntax: Object Hierarchy. Set
Ex: Window("Flight Reservation").WinRadioButton("Business").Set
c) Selecting/Deselecting check boxes
Syntax: object Hierarchy. Set “ON/off”
Ex:
Window ("Flight Reservation"). Dialog ("Open Order").WinCheckBox("Order No.").Set "ON"

5) Select Method à It is used for selecting an item from a combo box or list box.
Syntax: Object hierarchy. Select “item”
Ex:
Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12572

6) GetVisibletext: It returns Text from the specified area.
Syntax: Variable =object hierarchy.GetVisibleText
Ex:
X=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
msgbox X

7) GetROProperty Method  à It returns current object property value. It can be used for getting any object’s, any property value.
Syntax: Variable = object hierarchy.GetROProperty (“property name”)
Ex:
x=Window("Flight Reservation").WinEdit("Tickets:").GetROProperty ("width")
msgbox x

8) Navigate Method à It opens a specified URL in the Browser.
Syntax: object hierarchy. Navigate “URL”
Ex:
Browser ("Yahoo!").Navigate http://www.google.co.in/

9) GetItemsCount: It returns number of items in a combox.
Syntax: Variable=object hierarchy.getitemscount
Ex:
x=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
msgbox x

10) GetContent: It returns all items from a combobox.
Syntax: variable=object hierarchy.GetContent
Ex
x=Window("Flight Reservation").WinComboBox("Fly From:").GetContent
msgbox x

11) Exist property: It checks whether the object is available or not.
Syntax: Object hierarchy.exist(time in seconds)
Ex:
Window("Flight Reservation").Exist(5)


0 comments:

Post a Comment

TrainingHUB. Powered by Blogger.

Total Pageviews

THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

QTP Training in hyderabad

Sql Tutorial

Popular Posts

Our Facebook Page

TrainingHUB

Followers