How to put a reference image into the test

Best practices, code snippets for common functionality, examples, and guidelines.
HansSchl
Posts: 125
Joined: Wed Sep 19, 2018 10:05 am

How to put a reference image into the test

Post by HansSchl » Fri Oct 22, 2021 12:03 pm

Hi,

this is my first attempt at image-based verification. I watched the screencast and read through the manual pages, but they don't really help in my case so I hope someone here could tell me what to do. This is Ranorex 9.5.1, running on Windows 10, and fully licensed.

I want to verify that a rectangle in the AUT contains an image. I believe Validate -> ContainsImage would be the right thing to to.

The AUT has a complex and, above all, automation unfriendly GUI. In this case, it took me half a day to create the repository items that describe the rectangle, based on repeated trial and error. (Rx Spy is a great help!)

I added the validation to a recording, but the "Screenshot name" column needs to be filled in, and I have no idea how to place a reference screenshot in my recording. I had hoped the "..." button would give me a chance to take a screenshot, or to enter the path, or would let me select from the screenshots of repository items, but nope.

When I attempted to record the validation (like in the screencast), Rx created a new repo item rather than using the one which I had created, and recorded an image into that item. Then it did not let me drag the screenshot to the correct repo item.

I am completely lost...

Hans

Jacob
Certified Professional
Certified Professional
Posts: 120
Joined: Mon Mar 22, 2021 10:01 pm

Re: How to put a reference image into the test

Post by Jacob » Fri Oct 22, 2021 7:17 pm

Hi HansSchl,

Unfortunately it is not possible to share screenshots between repository items due to the hierarchy in place. That being said, there are two ways around this:
1. You can save a screenshot to your desktop, then use the "..." button to open a new window, then add the image from the desktop to the repo object that way.
2. You can use the second repo item you created, just drag it up to the existing Validation step in the Action Items table. After doing that, you should be able to select the screenshot from the "..." button.

--Jacob
Image

HansSchl
Posts: 125
Joined: Wed Sep 19, 2018 10:05 am

Re: How to put a reference image into the test

Post by HansSchl » Mon Oct 25, 2021 11:14 am

Hi Jacob,

thanks for your reply. I tried to follow the first suggestion but got stuck.

I added the validation action with "ContainsImage", then opened "Properties" from the context menu to make sure I don't miss anything. There are four places with "..." buttons, I assume you mean the "Image based" line, right? It opens the same "Edit image validation" dialog that opens when I click "..." in the action list's "Screenshot name" column. In this dialog, the only enabled operations are zoom in/out/100%. Ctrl+V doesn't work, nor can I drag and drop a file here.

For a change, I tried to add the screenshot by drag&drop, or by Ctrl+V, to a repository item, with no success either.

I guess I'm on a completely wrong track, or aren't I?

Regards
Hans