Can I prevent the Recorder from creating unnecessary code?

Ranorex Spy, Recorder, and Studio.
hena
Posts: 3
Joined: Wed Jul 30, 2008 12:21 pm

Can I prevent the Recorder from creating unnecessary code?

Post by hena » Thu Aug 07, 2008 3:46 pm

I just recorded a sequence of mouse activities. The following code shows one part of the script which clicks on a control.

Code: Select all

    Ranorex.LoggerInfo("User", "Find child by control id '1195'.")
    control = Ranorex.FormFindChildControlId(form, 1195);
    if control == 0:
        return 1
    Ranorex.ControlSetFocus(control);
    Ranorex.LoggerInfo("User", "Get the accessibility element of the control.")
    controlElement = Ranorex.ControlGetElement(control);
    if controlElement == None:
        return 1

    Ranorex.LoggerInfo("User", "Find child element in control by Role='Graphic', Name='Knoten' and Location=(66,136).")
    element = Ranorex.ElementFindChildLocation(controlElement, 40, "Knoten", "", 66, 136);
    if element == None:
        return 1
    Ranorex.LoggerInfo("User", "Click element 1 time(s) with left mouse button at offset=(47,11).")
    if Ranorex.MouseClickElement(element, Ranorex.MOUSE_LEFT_BUTTON, 47, 11, 1, 5187*timeScale) != 0:
        return 1
I found this code quite awkwardly and simplified it in this way:

Code: Select all

    Ranorex.LoggerInfo("User", "Find child by control id '1195'.")
    control = Ranorex.FormFindChildControlId(form, 1195);
    if control == 0:
        return 1
    Ranorex.LoggerInfo("User", "Click control 1 time(s) with left mouse button at offset=(47,11).")
    if Ranorex.MouseClickControl(control, Ranorex.MOUSE_LEFT_BUTTON, 47, 11, 1, 2000*timeScale) != 0:
        return 1
I wonder why Ranorex Recorder created a more complicated script. Is there a chance to prevent Ranorex Recorder from creating (IMO) unnecessary code? This would make the code easier to understand.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Fri Aug 08, 2008 10:57 am

You are right, the Recorder generates sometimes unnecessary code at the moment, this is usually a problem with autogenerated code.
I would suggest to edit and optimize the recorded code.

And now the good news: We are currently working on the next generation of the Recorder and the new version (V2.0) will generate a much simpler and quicker code.

Jenö
Ranorex Team