Wednesday 17 November 2010

QTP - Verify if an object is enabled or disabled

Leave a Comment
Verify Object Is Enabled or Disabled

'*********************************************************************
' Verify Object Is Enabled  
'*********************************************************************

' Pass a object to the function VerifyEnabled to ve verified
'Parameters: 
' obj - Object which is to be verified for enabled property

Public Function VerifyEnabled (obj)
   Dim enable_property
   'Get the enabled property from the test object
   enable_property = obj.GetROProperty("enabled")
   If enable_property <> 0 Then ' The value is True (anything but 0)
     Reporter.ReportEvent micPass, "VerifyEnabled Succeeded", "The test object is enabled"
     VerifyEnabled = True
   Else
     Reporter.ReportEvent micFail, "VerifyEnabled Failed", "The test object is NOT enabled"
     VerifyEnabled = False
   End If
End Function 

'*********************************************************************
' Verify Object Is Disabled 
'*********************************************************************

'' Pass a object to the function VerifyDisabled to be verified
'Parameters: 
' obj - Object which is to be verified for enabled property

Public Function VerifyDisabled (obj)
   Dim enable_property
   'Get the enabled property from the test object
   enable_property = obj.GetROProperty("disabled")
   If enable_property = 0 Then ' The value is False (0) - Enabled
     Reporter.ReportEvent micPass, "VerifyDisabled Succeeded", "The test object is disabled"
     VerifyDisabled = True
   Else
     Reporter.ReportEvent micFail, "VerifyDisabled Failed", "The test object is enabled"
     VerifyDisabled = False
   End If
End Function


'*********************************************************************
' ' Actual code begins here.
'*********************************************************************
' To check if the Button is enabled or not.
' If enabled then call another function (ClickOnButton to click on Button )

Set Obj=Browser("").Page("").WebButton("")
If VerifyEnabled(Obj)=True Then
    Call ClickOnButton(Obj)
End If 

0 comments:

Post a Comment

Wednesday 17 November 2010

QTP - Verify if an object is enabled or disabled

Verify Object Is Enabled or Disabled

'*********************************************************************
' Verify Object Is Enabled  
'*********************************************************************

' Pass a object to the function VerifyEnabled to ve verified
'Parameters: 
' obj - Object which is to be verified for enabled property

Public Function VerifyEnabled (obj)
   Dim enable_property
   'Get the enabled property from the test object
   enable_property = obj.GetROProperty("enabled")
   If enable_property <> 0 Then ' The value is True (anything but 0)
     Reporter.ReportEvent micPass, "VerifyEnabled Succeeded", "The test object is enabled"
     VerifyEnabled = True
   Else
     Reporter.ReportEvent micFail, "VerifyEnabled Failed", "The test object is NOT enabled"
     VerifyEnabled = False
   End If
End Function 

'*********************************************************************
' Verify Object Is Disabled 
'*********************************************************************

'' Pass a object to the function VerifyDisabled to be verified
'Parameters: 
' obj - Object which is to be verified for enabled property

Public Function VerifyDisabled (obj)
   Dim enable_property
   'Get the enabled property from the test object
   enable_property = obj.GetROProperty("disabled")
   If enable_property = 0 Then ' The value is False (0) - Enabled
     Reporter.ReportEvent micPass, "VerifyDisabled Succeeded", "The test object is disabled"
     VerifyDisabled = True
   Else
     Reporter.ReportEvent micFail, "VerifyDisabled Failed", "The test object is enabled"
     VerifyDisabled = False
   End If
End Function


'*********************************************************************
' ' Actual code begins here.
'*********************************************************************
' To check if the Button is enabled or not.
' If enabled then call another function (ClickOnButton to click on Button )

Set Obj=Browser("").Page("").WebButton("")
If VerifyEnabled(Obj)=True Then
    Call ClickOnButton(Obj)
End If 

No comments:

Post a Comment