Image validation user code issue

Bug reports.
SPluemper
Posts: 14
Joined: Thu Jan 28, 2016 3:52 pm

Image validation user code issue

Post by SPluemper » Wed Nov 23, 2016 12:23 pm

Hello,
STR:
* Add a new test case
* Add a new Recording Module in this test case
* Click at "Record"
* Do an action of your choice, for example a simple mouse click
* Add an image base screenshot validation
* Stop the recording
* Convert both commands to user code
* Test it

Independent if the tests fails or not, the compiler returns no error and the test is running.

* Enter the user code
* Remove the lines which ends the first method and start the second method so that you have only one method with both actions in it
* Test it again

It will still run because Ranorex creates a new empty method for the second action.

* In the recording module, remove the second line (which only calls the empty method)

Now the compiler stops with the error

Code: Select all

The name '<Screenshot name'> does not exists in the current context (CS0103)
You cannot fix it by creating a new user code function with the still existing function and copying the lines back to it.
This also happens if you try to copy the Validate.ContainsImage() line to another test record, unlike all other methods I have used until now like Validate.Attribute() or others.

Is the screenshot bundled to the action line in the recording module ?
How can I create a copy a user code image validation to another method or module?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3954
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Image validation user code issue

Post by odklizec » Thu Nov 24, 2016 10:32 am

Hi,

At first, if you want to convert multiple selected recorded steps at once, use Merge Items to User Code Item command, which merges all selected actions to single user code method. So then you don't have to delete/edit converted actions in UserCode.cs.
MergeItemsToUserCodeItem.png
MergeItemsToUserCodeItem.png (8.8 KiB) Viewed 666 times
At second, if you want to move image-based validation/action, you must copy "Image Feature Data" region stored in Recording.cs file (you can find this section collapsed near the end of the .cs file) and paste this region data to recording (its UserCode.cs) or code module of your choice (along with converted user code method)...
ImageFeatureData.png
ImageFeatureData.png (14.52 KiB) Viewed 666 times
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

SPluemper
Posts: 14
Joined: Thu Jan 28, 2016 3:52 pm

Re: Image validation user code issue

Post by SPluemper » Fri Nov 25, 2016 9:25 am

Hi,

thanks for the two great tips. I never selected more than one line to convert them to user code, so I never saw the merge command before.

And image test moving to another method is now also working.

Thanks.
Have a nice weekend.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3954
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Image validation user code issue

Post by odklizec » Fri Nov 25, 2016 9:30 am

You are welcome! ;) Have a nice weekend too.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

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

Re: Image validation user code issue

Post by Stub » Fri Nov 25, 2016 9:34 am

Same. Didn't realise you could merge recording steps like that. And I had completely missed that Imaging.FindOptions.Default property, which I have now applied to my Ranorex user code. Ta.