Page 1 of 1

Screenshot data get lost, when converted to User code

Posted: Thu Dec 30, 2010 10:50 pm
by slavikf
Screenshot data get lost, when converted to User code
Scenario:
- Record simple script:
- 1) Start Calc
- 2) Validation: Select Calculator -> Image -> Contains -> Select some region
So, you have 2 steps in your Recording.rxrec. Now
- convert both steps to User Code
- Cut code from 2nd method (Validation) and paste into 1st method (Calc start) and delete 2nd (now empty) method from recording and from code...
DEFECT:
- At this point Ranorex remove something from script's code or from resource library, so now i getting compile errors:
  • The name 'ElementCalc_Screenshot1_Options' does not exist in the current context (CS0103) - C:\Users\capture1\Documents\RanorexStudio Projects\screenshot test\screenshot test\Recording1.UserCode.cs:35,89
  • The name 'ElementCalc_Screenshot1' does not exist in the current context (CS0103) - C:\Users\capture1\Documents\RanorexStudio Projects\screenshot test\screenshot test\Recording1.UserCode.cs:35,64
Is there is a way to disable such "optimization"?

P.S.: Also, i found, that if i do it other way (cut code from 1st method and paste it to 2nd method) - it works. So it means, that data getting lost at moment, when method with Screenshot parameters are removed from original function... :-(

Re: Screenshot data get lost, when converted to User code

Posted: Fri Dec 31, 2010 5:30 pm
by Support Team
Hi Slavikf,

thanks for this report. I will make a bug report out of it.

The problem is that 'ElementCalc_Screenshot1_Options' is in the Recording1.cs file, which gets automatically generated, while the usage of this variable is in the Recording1.UserCode.cs file.

We will have to move variables used by the usercode to the Recording1.UserCode.cs file as well, when converting an action list entry to usercode.

For now you could do that manually:
1) select a variable used by the user code
2) go to menu search/find and find all occurrences
3) copy the definition of the variable to the <recording>.UserCode.cs file
4) only then you should delete the entry in the action list

Cheers, Roland