Showing posts with label Winbutton. Show all posts
Showing posts with label Winbutton. Show all posts

Monday, September 3, 2012

Child Objects Method in QTP


 Child Objects

              This method will display the count of the needed objects that we needed specifically from the application.

For Example:

           1. We might be need the no. of Links (Links)
           2. We might be need the no. of Buttons (WinButton, WebButton)
           3. We might be need the no. of Editbox (WinEdit, WebEdit)  

To display the count of the objects present in the same name we can declare the below syntax.

Example: 1

'Display the count of the links present in the google page:

Set lnk=Description.Create
lnk("micclass").value="Link"
Set brw=Description.Create
brw("name").value="Google"
Set olinks=Browser("name:=Google").Page("title:=Google").ChildObjects(lnk)
msgbox olinks.count

Example: 2

'Display the count of the buttons present in the qtp default flight application landing page:

Set btns=Description.Create
btns("micclass").value="WinButton"
Set dlg=Description.Create
dlg("name").value="Login"
Set ocollection=Dialog("text:=Login").ChildObjects(btns)
msgbox ocollection.count

Example: 3

'Display the count of the Edit Boxes present in the qtp default flight application landing page:

Set btns=Description.Create
btns("micclass").value="WinEdit"
Set dlg=Description.Create
dlg("name").value="Login"
Set ocollection=Dialog("text:=Login").ChildObjects(btns)
msgbox ocollection.count


Monday, August 6, 2012

Generation of Scripts for Windows Application

Record and Playback:

Dialog("Login").WinEdit("Agent Name:").Set "admin"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

Above scripts are recorded for default "flight reservation" free windows application available in QTP,

Variation of scripts for Windows and Web:

There are some difference in scripts that we can see here for recording windows and web application,
for web application we are using the "object" of the text box as WebEdit (" ") and for button "WebButton"
for windows application the "object" of the text box here we used as WinEdit(" ") and for button "WinButton".

By keeping the above recorded scripts to bring up the same for the basic framework level we need to implement some validation codes to run the recorded scripts once giving play back in QTP,

Systemutil.Run(""C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4b.exe")
Dialog("Login").Active
Dialog("Login").WinEdit("Agent Name:").Set "admin"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

The above code will give the best output while QTP play back the scripts.

Dialog("Login").Active -  Indicates the login window should active to display whenever the user playback the scripts