Forum Discussion

MichaelMcFarlan's avatar
MichaelMcFarlan
Contributor
13 years ago

Picture splice/merge possible?

I'm working on a script that compares lots of values with an application vs a website. I've used Log.Picture to get the exact regions I want and that is working great. I was wondering if there was a way to merge these pictures into one so I can compare the results. As is I to compare them by opening one in the Image Viewer and then selecting the other in the Test Log and viewing it from the Picture tab. This is sort of functional, but far from elegant or as simple as it could be.



I've looked in the help file and it looks like functions there are just 0.001% away from being able to do this how I want. You can stretch images and get sections of them, even make blocks of them different colors from the looks of it... but I'm either not seeing how to put complete different pictures together or it's not built in yet.



Any ideas?

9 Replies

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Michael,


    The manual comparison is error-prone as you can miss some slight differences. You can automate comparing images with the Compare method. To specify the images to be compared, you can just specify the appropriate test objects, there is no need to save the images to files and then compare them from the files:



    ' window1 and window2 are the test objects that correspond to the windows to be compared



    ' Get the Picture object for one of the windows

    picture1 = window1.Picture(...)



    ' Compare the images

    picture1.Compare(window2, ...)



    See also Comparing Images in Scripts and other topics of the Region Checkpoints section.

  • Oh, I didn't think of what I said that way, but I can see how it would be understood like that. These images aren't meant to be the same at all, rather they just contain similar calculations, from two different sources. I'm just comparing the results, and the easiest way to do that is with screenshots so that I can be sure all input was made correctly (it's a slightly dynamic test). There are multiple inputs and multiple resulting calculations and using the log to compare to easily interpret the results does not work very well, whereas the picture screenshots are much clearer.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    If you're comparing calculation results between the web and the main app, why are you using Regions to compare rather than capturing the contents of the relevant controls into some sort of data object (ODT or something else, even) and doing the comparisons that way?  Seems that using region comparisons, assuming you have access to the control contents, is like using a screw driver to hammer in a nail... it works, but it's not the best tool for the job...
  • Let me explain this a bit clearer (it seems clear when I write it but when I see how you're understanding it I see how it doesn't make sense).



    I am getting the results and storing them in objects and then comparing them. However, if there is a discrepancy between the results of the application and the web page, I want to be able to view a screenshot with both the application input/results and webpage input/results (that would only require splicing two images together). Given that the test is fluctuates in what prompts are available, there is no simple way to make sure that the data was entered as expected in both the webpage and application. A much easier way would be to view the screenshot which makes it clear if the tests were setup as expected, and if the discrepancy is actually do to an error in calculations as opposed to just some input not being done the same way.



    This makes it sound very confusing and complicated, but I really don't feel like it is. If I still doesn't make sense, I ask you just to trust that I am 99% sure that screenshots are the easiest way to go and any alternative would be 50x more complicated then having an image with all the data input and results clearly visible.



    Which leads me back to trying to splice the screenshots together..



    Edit: Robert, your analogy made me laugh. My first experimenting with carpentry tools was trying to nail a screw into a block of wood when I was 4 or so.
  • Do you want to splice them togather for someone to do a manual comparison?
  • Yes, but keep in my mind that I'm only doing this for ones where I already know that the data results don't match. That way I (and the person who will need to fix the application to get matching results) can just see which ones had problems and exactly why they had problems.



    The reasoning behind this doesn't really matter all that much, I just want to know if TestComplete has the ability to do this somehow.



    Maybe I should just reposition the windows and have it take a screenshot of the full desktop, seems unnecessarily clunky and ugly though. Not to mention with two monitors that would mean huge pictures with lots of extra content I would rather not have.
  • Looking through the help, you could probably do it within TestComplete.  It may be very manual.



    Create a new picture object by loading a blank image that is large enough to contain both your rectangles that you want to splice togather.

    It would be something like

    Set p = utils.Picture.LoadFromFile("my large blank image")



    Next, let's assume that you have your images for your web page and application rectangles already loaded into pictures called w and a respectively.



    Each picture has a Pixels property.



    You should be able to copy the pixels from the first of your images (ie, picture w) into the pixels in the first half of p.

    You should be able to copy the pixels from the secondof your images (ie, picture a) into the pixels in the second half of p.



    After completing the copying, save out the contents of p to an image or post it to the log.

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Michael,


    Try using the following code:




    ' window1 and window2 are the test objects that correspond to the windows to be compared

    ' Compare the images

    Regions.Compare(window1, window2, ...)




    The Regions.Compare method posts images of both windows to the test log side by side (see the attached image). You will be able to explore both images or click the Comparison Mode button to highlight differences.

  • Alex, thanks! That works pretty close to what I wanted. I should have tried it the first time, but I thought that you were talking about comparing images for content.. which it seems compare is primarily meant for but it works decently for just seeing two pictures in the log. I feel like this could be made a slightly bigger feature, but then again I'm not sure how often it would be used.