ranorex

How do I modify recorded ranorex scripts using c#


I am a newbie to Ranorex. I have a couple of recorded ranorex scripts. I want to modify them using C#. In Ranorex studio, when I click on View Code from a recorded script, it says that I cannot modify the C# code that is displayed there. I searched online about how to do this but haven't found an answer. I would appreciate if anyone can help. I am using Ranorex Studio v7.0.1 on a Windows Server 2012 R2.

Alternatively, if I can only create the code using C# and use it with Ranorex, I am fine with that approach as well, although it might take some more time.

Thanks


Solution

  • To convert a recorded part to user code that can be edited:

    1. Right click on the action in the rxrec file
    2. Select "Convert to user code"

    What this will do is create a user code element for which the code can be edited.

    To create a user code action yourself:

    1. Click "Add new action" in the rxrec file
    2. Click on "User code"
    3. Double click the created action and you will be directed to the code editor

    More info here: https://www.ranorex.com/help/latest/lesson-5-ranorex-recorder/user-code-actions

    When i worked with ranorex - user code actions were the way i did my automation logic. Never used recordings.

    I also suggest you learn more about the Ranorex Repository as you will need the knowledge for it to successfully develop user code actions and automation logic. Info here: https://www.ranorex.com/help/latest/lesson-6-ui-mapping-with-ranorex-repository

    Later on you can start using code modules. But until you have better knowledge of Ranorex and automation principles i suggest you do it through the recording modules as you have a lot of reference and helping methods/actions there.

    Another point to remember is you can always add an action and check the code to see how it works and try to implement it yourself throught the user code actions.

    Martin