Validate.CompareImage vs ToolTips

Class library usage, coding and language questions.
User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Validate.CompareImage vs ToolTips

Post by Stub » Wed Mar 22, 2017 3:31 pm

Using Ranorex 6.2.1 on Windows10, I've been looking at how to validate a tooltip appears correctly. I cannot find this tooltip in Ranorex Spy (even with the use of instant tracking) so I've been having a play with image validation.

Depending on which Ranorex.Imaging API I use the image I capture sometimes INcludes or EXcludes the tooltip!

When I use Ranorex.Validate.CompareImage, this takes a screenshot of my element EXcluding the tooltip. The screenshot I'm comparing it to INcludes the tooltip, so obviously the Ranorex.Validate.CompareImage call fails. At this point the .rxlog notes that the "Expected image" INcludes the tooltip, the "Searched Image" EXcludes the tooltip, and my "Difference images" correctly highlights the difference.

This was when I started calling the Ranorex.Imaging APIs individually to see what each did. I output the bitmap to the .rxlog file using:

Code: Select all

Report.LogData(ReportLevel.Info, "CaptureImage", bitmap);
At this point I noticed that my tooltip flashed off, on, off, on while it executed the series of image acquisition calls.

* Ranorex.Imaging.CaptureCompressedImage INcludes the tooltip.
* Ranorex.Imaging.CaptureDesktopImage EXcludes the tooltip.
* Ranorex.Imaging.CaptureImage INcludes the tooltip.
* Ranorex.Imaging.CaptureDesktopImageWithSurroundArea didn't do what I expected it to.
* Ranorex.Imaging.CaptureImageAuto EXcludes the tooltip.
* Ranorex.Imaging.CaptureImageHidden EXcludes the tooltip.

Question: Is there any way to control how Ranorex.Validate.CompareImage acquires the screenshot of the element that I supply it? I'm guessing that it calls either CaptureDesktopImage, CaptureImageAuto or CaptureImageHidden.

I can of course use non-tooltip-sensitive Ranorex.Imaging API to grab the element's current screenshot and then Ranorex.Imaging.Compare to compare the two bitmaps directly, but this means I lose the excellent difference images that the Ranorex.Validate.CompareImage API offers.

:

Later I noted that it appears as though Ranorex.Imaging.Compare(Element, Bitmap) INcludes the tooltip, unlike Ranorex.Validate.CompareImage.

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Validate.CompareImage vs ToolTips

Post by Vega » Wed Mar 22, 2017 4:16 pm

  • What kind of application are you testing?
    Can you provide a snapshot?
I think if you could find the tooltip in the tree, this would be a more simple approach. I know you couldn't find the tooltip via instant tracking / spy, but try this XPath in spy while the tooltip is present:

//*[?'SearchString']

Replace SearchString with the text of the tooltip. This should locate any and all elements that contain the text you specify.

Sometimes tool tips / popups are not spawned from the parent object you are expecting. For instance many popups are actually generated by the browser form object, and not the DOM itself.

I'm not 100% sure on your image validation questions and will have to look into it, just hoping the above info will be helpful in the meantime.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Validate.CompareImage vs ToolTips

Post by Stub » Thu Mar 23, 2017 3:20 pm

Ah, I had been trying variations of "//element['SearchString']" but I didn't know about using "//*" and "[?". I gave that suggestion a go but still can't find anything, so I've stuck with my image capturing findings for the time being.

I think the snapshot has absolutely everything in it, and it's a C++/MFC/legacy Windows application that I'm testing.

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Validate.CompareImage vs ToolTips

Post by Vega » Fri Mar 24, 2017 3:49 pm

Would it be possible for you to provide a snapshot with the tool tip present?

If you are having trouble creating the snapshot with the tool tip present, you can make a recording which causes the tooltip to be present and then creates a snapshot - all within the recording.