Wednesday, April 20, 2011

QTP Count the Number of Open Browser Sessions

QTP Count the Number of Open Browser Sessions

' Create a Description Object

Dim iDesc

Set iDesc = Description.Create

' Assign the micclass Property
iDesc("micclass").value="browser"

'Get the child objects using getChildObjects
Set iObj = Desktop.ChildObjects(iDesc)

'Displays the count
MsgBox iObj.Count

QTP : GetTOProperties of Image Object

'Image
Set Img=Browser("Login").Page("Login").Image("American English")
Set tImg=Img.GetTOProperties()
MsgBox typename(tImg)
icount=tImg.Count-1

For i=0 to icount
 sName=tImg(i).Name
 sValue=tImg(i).Value
 Reporter.ReportEvent micPass,"Property:="&sName&"Value :="&sValue,""

Next

QTP GetTOProperties for Page Object

Set Pg=Browser("Login").Page("Login")
MsgBox typename(Pg)
Set toPg=Pg.GetTOProperties()

'Dim i,icount
icount=toPg.Count-1

For i=0 to iCount
     sName=toPg(i).Name
     sValue=toPg(i).Value
 Reporter.ReportEvent micPass,"Property:=" & sName & " Value :="&sValue,""
Next

QTP Get the Properties for Browser Object

'Get the Properties for Browser Object

Set br=Browser("Login")
Set toBr=br.GetTOProperties()
'Dim i,icount
icount=toBr.Count-1


For i=0 to iCount
     sName=toBr(i).Name
     sValue=toBr(i).Value
 Reporter.ReportEvent micPass,"Property:=" & sName & " Value :="&sValue,""
Next

QTP : GetTOProperties of Web Edit Object

' Program to get the Test Object Properties of a Web Edit Field
' Assumption:Objects are already learned into the Object Repository

Set we=Browser("Login").Page("Login").WebEdit("usernameField")
Set toProps=we.GetTOProperties()


Dim i,icount
icount=TOProps.Count-1
For i=0 to iCount
     sName=TOProps(i).Name
     sValue=TOProps(i).Value
 Reporter.ReportEvent micPass,"Property:=" & sName & " Value :="&sValue,""
Next

Output :

Property :=type Value :=text
Property :=name Value :=usernameField
Property :=micclass Value :=WebEdit
Property :=html tag Value :=INPUT