Forum Discussion

ajitkumar163's avatar
ajitkumar163
Occasional Contributor
10 years ago

Finding one Image inside another Image is Failing

Hi,



While finding an image inside another image the script is getting failed.

Steps to reproduce



1> I saved an image in the desktop and copied the same image in the Regions folder under Store(store/regions) of testcomplete



Dim picture1,pict,w,win

sub testdesktop()

 set win=Aliases.explorer.Window("CabinetWClass", "Desktop", 1)

 win.Maximize

 win.Activate

 Set w = Sys.Desktop.ActiveWindow '.Picture()

 Set picture1 = w.Picture

 log.Picture(picture1)

 

' Loads the sought-for image

  Set pict = Utils.Picture

  pict.LoadFromFile(ProjectSuite.Path&"TestProject1\Stores\Regions\pic1.png")

 

  Set rect = picture1.Find(pict)

 

  If rect Is Nothing Then

    Call Log.Warning("The image was not found.")

    Exit Sub

      else

   log.Message "required image was found"  

  End If

 

  win.Restore

 

end sub



While running the above program the control always goes to the "Image was not found".I took help of http://support.smartbear.com/viewarticle/57040/.



NOTE: While I am trying to find the image saved in Store/regions inside the webpage,the same scenario works for me, below is the program



Public Function Find_Picture_Program(URL,ImageName)

  'Dim url, page, picture, pict, rect, img, x, y



  ' Launches the web browser and opens the web page

  Browsers.Item(btIexplorer).Run(URL)

  Set page = Sys.Browser.Page("*")



  ' Obtains the image of the browser window

  Set picture = page.PagePicture

 

  ' Loads the sought-for image

  Set pict = Utils.Picture

  pict.LoadFromFile(ProjectSuite.Path&"TestProject1\Stores\Regions\"&ImageName)



'  ' Loads the sought-for image

'  Set pict = Utils.Picture

'  pict.LoadFromFile("D:\googlepageImage.png")



  ' Searches for the image within the browser window

  Set rect = picture.Find(pict)

  If rect Is Nothing Then

    Call Log.Warning("The image was not found on the page.")

    Exit Function

    else

   log.Message "required image was found with in the Web Page"  

  End If



End Function



Requesting to provide the solution to the above problem



Thanks,

Ajit
No RepliesBe the first to reply