Forum Discussion

DevaV's avatar
DevaV
Contributor
14 years ago

About TestObj.Picture() method

Hi,



We have to take a screenshot of an dialog for which we used TestObj.Picture method. The screenshot taken using ALT + Print Screen (manually) and TestObj.Picture method differs. We need to take the screenshot exactly as the dialog.



Please let us know,

1) How test-complete takes the screenshot?

2) Why does it differs from the screenshot taken manually and using test-complete?

3) Is there any settings or functions needs to be modifed to take screenshot as manually?



Attached the images for your reference.



Note : We use same system settings while taking manually and through test-complete

9 Replies

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi Deva,



    Graphical tools might slightly distort the image while saving due to the algorithms used. AFAIR Support's recommendations, it was recommended to use either Paint or the means provided by TC.
  • Thanks for the reply Alexei Karas.



    Would you mean, we wont be able to get the same image as in Paint (printscreen ) gives? [ Do you mean algorithms used in Paint and TC is different]



    We have a situation where the screens required for Help contents for multi language support [Once in every 6 months], So automation would be the ideal choice, hence client expects the quality of the image MUST be same as in Paint.  what would you suggest?



    Please suggest us with detailed information.


  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi Deva,



    I mean that images saved by TestComplete means will work for image comparisons and images saved with Paint most probably will work either. There is a chance that image comparison against images saved by other tools will fail.

    Also note, that image comparison is highly unreliable as the actual image highly depends on OS version, screen resolution, color depth, etc. Most probably, the use of object and/or property checkpoints will be much more reliable.
  • Alexei Karas, hope you have not understand my query.



    Let me explain again here.



    We are not trying to compare the images.



    We are worrying about the quality of the image taken manually and taken using test-complete (TestObj.Picture()) differs.



    My question is, why do the quality of the image differs when system settings are same. Please do refer the image attached in the first query. you would get clear idea.
  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi Deva,



    You provided no details on what tools and with what settings were used to get both images. I can see a slight difference between two images you've provided, but with a wild guess that one image was saved as a loss-less .bmp while another one was saved as .jpg with maximum compression, I am not wondered that they are slightly different.
  • Sorry Alexei Karas!



    Hope I was very clear, that only asking about the quality of the images and not about comparing images. It was very clearly asked that why there is the difference in the quality of the images when it was taken during testcomplete (Testobj.Picture() method) and manually (Printscreen) with the same system settings.



    Again, the question is why do the quality of the image taken using Testobj.Picture() is very low compared to the printscreen.
  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi
    Deva,



    > [...] why do the quality of the image taken using Testobj.Picture() is very low compared to the printscreen.


    Testobj.Picture() method just takes the picture, but do not save it and the quality of saved image can be lowered at both steps - when taking the image and when saving it. To control the quality of the saved image in TestComplete you can check and adjust the settings under <your test project>|Properties|General|Images node.
  • Hi Alexei Karas,



    I don't find difference in the quality of the image after modifying the settings of the image in test-complete properties.
  • Deva,


    The Aero theme of the Windows operating system provides semi-transparent borders. These borders look nice, but it is difficult to use them in automated testing as the colors of their pixels depend on what is below the border. If there are blank white areas below the border, the pixels will have some light color, if you have a dark region or some black text below the border, the pixels will have darker colors.


    As you know, TestComplete can capture window images and compare them. The primary goal for the image-capturing functionality is to "produce" images that are suitable for checkpoints and automated tests. That is why, by default, TestComplete disables all the "pretty-looking" OS features before taking a screenshot and restores them after it captures the screenshot. The resulting image looks a bit different, but it is more suitable for automated testing than the original one. TestComplete switches the OS settings every time you call Picture() or other similar methods. It switches the settings quickly, so, most likely, human eyes are not able to recognize the changes.


    I don't think that these "different" images provide any barrier in understanding the text of your help system :-), however, I'd agree that the "Aero" images look prettier :-). So, the solution is to disable TestComplete's default behavior and let it capture images as they are. To do this, turn off the Disable DWM before capturing image project property:

    * Open your project in TestComplete.

    * Right-click the project node in the Project Explorer and choose Edit | Properties from the context menu. This will open the project editor and activate its Properties page.

    * Choose General[b/] from the tree on the left of the page (the topmost item). You will see the "Disable DWM..." check box on the right, in the Images section.

    * Clear the check box and save the changes.