Wednesday, April 20, 2011

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

Tuesday, April 19, 2011

QTP : Create a text file using File System Object

'Create a file system object
Set fso=createObject("Scripting.FileSystemObject")

'Create a file over the file system object -
' Parameters -
' 1 - Path of the object
' 2 - True - denotes overwrite the file if it exists
set file1=fso.CreateTextFile("C:\test.txt",True)

' Write the text into the file
 file1.write("hello world");

' file 1 is a TextStream Object
' Close the file
file1.close