Page 1 of 1

Keeping changes made on generated code

Posted: Mon Jan 12, 2009 6:36 pm
by schachner
I' ve recorded some actions and manually
modified the generated code. But my changes got lost when
I replayed the recording.
Is there a way to prevent my own own changes from being overwritten?

Btw: When is the code re-generated?

Posted: Tue Jan 13, 2009 8:51 am
by Support Team
Hi,

Ranorex Recorder or Ranorex Repository generated code files should not be changed manually. Currently you'll have to extract the code generated by Ranorex Recorder to your own code files if you want to extend it with user code. In future versions we're planning to provide a mechanism to extend recorded actions directly within the Recorder's action table.

The code is generated automatically every time you edit and save the recorded actions.

kind regards,

Christoph,
Ranorex Support Team

Posted: Tue Jan 13, 2009 4:40 pm
by darkness
Support Team wrote: The code is generated automatically every time you edit and save the recorded actions.
Unfortunately it is also regenerated when the project is opened after it had been closed which makes changing the code more or less useless. This makes it impossible to parameterize recorded tests and identification of controls.

Posted: Tue Jan 13, 2009 5:40 pm
by Support Team
We are currently discussing about some recorder extensions, this will solve this problem, but the new feature will only come with V2.1.

You can do the following if you want to change and extend a recorder generated code.

1. Rightclick the project in the Project Explorer and select "Add New Item..."
2. Add a new C# class to the project
3. Open the source of the Recording project
4. Select and copy the code with Ctrl+A, Ctrl+C
5. Open the new generated C# class
6. Paste the code of the Recording project: Ctrl+A, Ctrl+V
7. Change the class name and extend the code
8. Call the static Start function of the new class in the Main function of the Project (Program.cs->Main)

You can convert a Recording project into a C# project manually this way.

Jenö
Ranorex Team