Forum Discussion

maddy_jay's avatar
maddy_jay
New Contributor
7 years ago

Cant open Image of an object in python PIL

I have been trying to open the image of an object in Testcomplete using Python PIL library by converting the Testcomplete object into Picture object. But it is showing error as "AttributeError: The object does not support this property or method".

My code :

Sample_object = Sys.Process("vncviewer_latest")

Sample_pic_obj = Sample_object.Picture()

fin = Image.open(Sample_pic_obj)

 

How to solve this issue ?

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The "Picture" method is not a method of the Process object...  You're trying to call the "Picture" method of a process object so, since that is not a valid method, you get that error.  If you want to take a picture of some part of your application, you need to find some sort of window or visual object to call the Picture method on....

    • maddy_jay's avatar
      maddy_jay
      New Contributor

      Thanks for your valuable input !!

      I tried with window also, still get the same error.

       

      Sample_object  = Sys.Process("vncviewer_latest", 2).Window("vwr::CDesktopWin", "161.65.441.25 - VNC Viewer", 1)

       

      But it works, if I saved the image in hard disk and access it by using Path.

       

      fin = Image.open("D:\\Sample\\demo.jpg")

       

      I think Python Imaging Library does not accept the Image Format provided by Picture() method in Testcomplete.

       

      Any suggestion to overcome this problem ?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        you are correct.  The "Picture" object returned by the Picture method of a desktop object is not an image file like a jpg, png, gif, bmp, etc...  To actually create an image for you to process, you'll want to first call the "SaveToFile" method off of the Picture object (which you did) to create the corresponding image which you can then access as you would any other image.

         

        Here's the reference for the TestComplete "Picture" object...

        https://support.smartbear.com/testcomplete/docs/reference/program-objects/picture/index.html