QTP Sample Scripts

Capturing the runtime object prop val by using GetROProperty()

Option Explicit
Dim ie,url,expval,actval
Public Function Launch_Browser(url)
   Set ie=CreateObject("InternetExplorer.Application")
   ie.visible=True
   ie.ToolBar=1
   ie.Navigate url
   Set ie=Nothing
End Function
Call Launch_Browser("http://www.yahoomail.com/")

If (Browser("Yahoo! Mail: The best").Exist) Then
 Reporter.ReportEvent micPass,"Checking the Browser Exist","Browser Exist"
 Else
 Reporter.ReportEvent  micFail,"Checking the Browser Exist","Browser Does not Exist"
End If
expval=0
actval=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("login").GetROProperty("disabled")
If (expval=actval) Then
 Reporter.ReportEvent micPass,"Checking Enabled prop of UserID","UserID Enabled"
 Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("login").Set "jampani"
 Else
 Reporter.ReportEvent  micFail,"Checking Enabled prop of UserID","UserID Disabled"
End If
Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("passwd").Click
expval=0
actval=Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("passwd").GetROProperty("Disabled")
pwd=crypt.Encrypt("password")
If (expval=actval) Then
 Reporter.ReportEvent micPass,"Checking the enabled prop of  Password","Password Enabled"
 Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("passwd").SetSecure pwd
 Else
 Reporter.ReportEvent  micFail,"Checking the enabled prop of  Password","Password Disabled"
End If

Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebButton("Sign In").Click
If (Browser("Yahoo! Mail: The best").Page("(131 unread) Yahoo! Mail").Link("Sign Out").Exist) Then
 Reporter.ReportEvent micPass,"Checking the login successful","Login success"
 Browser("Yahoo! Mail: The best").Page("(131 unread) Yahoo! Mail").Link("Sign Out").Click
 Else
 Reporter.ReportEvent  micFail,"Checking the login successful","Login failed"
End If
Browser("Yahoo! Mail: The best").Close