User code within a recording module

Ask general questions here.
simmisj
Posts: 19
Joined: Tue Feb 27, 2018 10:12 am

User code within a recording module

Post by simmisj » Wed Mar 07, 2018 12:47 pm

Hi.
I need to use user code in my recording module to find the correct document to work with. I have created a User Code Collection and a method inside that called FindDoc(). Since the GUI displays the documents in random order I need to be able to automatically find the correct document to work with. In my method I need to read a label and check it against the value I need, if it is not the value then I need to press a key combination to advance to the next document and so on. Return when the correct value has been found or report a failure if the correct value is not found within some tries.

Pseudo code should be something like this:

Code: Select all

string valueToSearchFor = "123";
for(int i = 0; i < 3; i++)
{
    string currentvalue = GetValueFromLabel();
    if(valueToSearchFor.Equals(currentvalue))
    {
        // Return from the code since we found the document and want the recording module to continue
    }
    else{
        // We did not find the correct document. Key combination to advance document. Continue iteration.
    }
}
Report.Failure("The document is not there. Could not find document.");
P.S. The documentation that I found just explains how to create the classes and reference them in the recording module. Which is great and helped but I am not sure how to address the items I have recorded like the label where the value to search for would be located at.
https://www.ranorex.com/help/latest/use ... de-library
Last edited by simmisj on Wed Mar 07, 2018 1:07 pm, edited 1 time in total.

simmisj
Posts: 19
Joined: Tue Feb 27, 2018 10:12 am

Re: User code within a recording module

Post by simmisj » Wed Mar 07, 2018 12:59 pm

Okay. Part of the solution is to access the repository where the UI elements are located. That way I can get the text of the label where the value is displayed. Which I then compare to the value I am looking for.

Now I am missing how to do a key combination. For example: "ctrl + p" within the code. This will advance to the next document.

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

Re: User code within a recording module

Post by odklizec » Wed Mar 07, 2018 1:52 pm

Hi,

The easiest way to learn, what code is used behind a certain action, is to add given action to recording module. Then right click the action and from context menu select View Code menu item (or use Ctrl+E shortcut). This should redirect you to code behind the selected recording action. 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