Thursday, 8 January 2015

UFT - QTP - How to click on Image on web page

                                        Link to Mandatory QTP /UFT Interview Questions to read before Interview

Function ClickOnImage(byval objPageName,  byval PropertyName, byval propertyvalue, byval Index)
 Set ObjPage= objPageName
   If Index ="" Then
    If ObjPage.Image(PropertyName&":="&propertyvalue).exist(10) then
    ObjPage.Image(PropertyName&":="&propertyvalue).highlight ' comment later
    ObjPage.Image(PropertyName&":="&propertyvalue).click
    Reporter.ReportEvent 4"ClickOnImage""Checking for lmage"& propertyvalue
    Reporter.ReportEvent micPass,"ClickOnImage","Image with Property " & PropertyName & "Property Value " & propertyvalue & "Found"
    Reporter.ReportEvent micPass,"ClickOnImage","Image with Property " & PropertyName & "Property Value " & propertyvalue & "Clicked"
    ClickOnImage =0
   Else
    Reporter.ReportEvent 4"ClickOnImage""Checking for Image"& propertyvalue
    Reporter.ReportEvent micFail,"ClickOnImage","Image with Property " & PropertyName & "Property Value " & propertyvalue & "was not Found or available"
    ClickOnImage = 1
  End if
 else
  If ObjPage.Image(PropertyName&":="&propertyvalue, "Index:="&Index).exist(10) then
   ObjPage.Image(PropertyName&":="&propertyvalue, "Index:="&Index).click
    Reporter.ReportEvent 4"ClickOnImage""Checking for lmage "& propertyvalue
    Reporter.ReportEvent micPass,"ClickOnImage","Image with Property " & PropertyName & "Property Value" & propertyvalue & "Found"
    Reporter.ReportEvent micPass,"ClickOnImage","Image with Property " & PropertyName & "Property Value " & propertyvalue & "Clicked"
    ClickOnImage =0
   Else
    Reporter.ReportEvent 4"ClickOnImage""Checking for lmage"& propertyvalue
    Reporter.ReportEvent micFail,"ClickOnImage","Image with Property  " & PropertyName & "Property Value" & propertyvalue & "was not Found or available"
    ClickOnImage = 1
  End if
End If
End function

                                        Link to Mandatory QTP /UFT Interview Questions to read before Interview

No comments:

Post a Comment