Represent multiple elements with a single repository item

There are times when it may be helpful to have a single repository item represent multiple UI elements. Examples include elements such as radio buttons and checkboxes. This feature is commonly used with code modules.

In this chapter

    tipp icon

    Screencast

    The screencast “Represent multiple elements with a single repository item” walks you through information found in this chapter:

    Watch the screencast now

    Necessary context

    The concept covered in this chapter is often used with code modules, which is an expert topic. In addition, you will find the example easier to understand if you are familiar with the RanoreXPath syntax and the Ranorex Spy tool. Use the links below to learn more about these advanced topics.

    Further reading

    Code modules are introduced in > Ranorex Studio expert > ⇢ Code modules.

    The RanoreXPath syntax is described in  > Ranorex Studio advanced > ⇢ RanoreXPath.

    Learn about the Ranorex Spy tool in > Ranorex Studio advanced > ⇢ Ranorex Spy.

    Example definition

    In the following example, one repository item represents two radio buttons. These radio buttons appear within the gender selection region of the database in the demo application.

    Gender selection radion buttons in demo application

    Gender selection radion buttons in demo application

    Track the repository item

    The procedure for creating a repository item to represent multiple elements is the same as for a regular repository item. Refer to the instructions below:

    Open Ranorex Spy 
    Start the demo application and click on the Test database register tab
    Track one of the gender selection radio buttons

    Tracking of a radio button in demo application

    Tracking of a radio button in demo application

    Tracked and identified female radio button UI element in the demo application
    Unique RanoreXPath specification for the female radio button in Ranorex Spy
    UI element browser tree displaying the defined path for the female radio button in Ranorex Spy
    Path editor for the female radio button in Ranorex Spy

    Generalize the RanoreXPath specification

    Follow the steps below to generalize the RanoreXPath specification so that it includes the second gender selection radio button of the demo application.

    Change the RanoreXPath specification as shown here

    Generalization of RanoreXPath specification

    Generalization of RanoreXPath specification

    Initial RanoreXPath specification that includes only the female radio button 
    Modified, generalized RanoreXPath specification that includes both radio buttons

    Multiple repository items detection

    Generalizing the RanoreXPath specification leads to the simultaneous tracking of both gender selection radio buttons in the demo application. This can be seen in Ranorex Spy.

    Multiple repository item tracking

    Multiple repository item tracking

    Positive match of two tracked radio buttons

    Found elements information in Ranorex Spy

    Found elements information in Ranorex Spy

    Ranorex Spy displays the match result in the lower left corner of the working environment

    Add the tracked item to the repository

    Finally, add the matched items to the repository.

    Adding matched item to repository

    Adding matched item to repository

    Select one of the matched repository items, open the context menu and click Add to repository

    Name the generalized repository item

    Like all repository items, the generalized repository item can be renamed to be more meaningful.

    Renaming of generalized repository item

    Renaming the generalized repository item

    Select the repository item representing multiple UI elements.
    Open the context menu to change the repository item name.