QTP Descriptive Programs Headline Animator

QTP Descriptive Programs

Wednesday, October 1, 2008

Script to get Names, Count and to Close Browsers

Prerequisites: Make sure your desktop contain 4 or 5 browsers with different websites

Code:

Set DescObj = Description.Create() 'Creates a New Empty descriptive Object
DescObj("MicClass").value = "Browser" 'Adding Properties and Values to Descriptive Object

Set DeskObj=Desktop.ChildObjects(DescObj) 'Assigning Object Reference to a Variable

Reporter.ReportEvent micDone, "The Browsers Count on Desktop ", " = "&DeskObj.count 'Prints Count of Browsers

For i=0 to DeskObj.count-1 'Making Loop to Print Browser Name and to Close browser
BrwName = DeskObj(i).Getroproperty("Name") 'Getting First Browser Name to a Variable
Reporter.ReportEvent micDone, "The Name of the Browser is", " = "&BrwName 'Printing First Browser Name
DeskObj(i).Close 'Closing the Printed browser
Next

Verification: confirm that all opened browsers are closed or not on desktop?

No comments: