Identify dynamic UI elements: Introduction | Ranorex Studio User Guide
Help CenterUser GuideRanorex Studio expert


Many applications contain so-called dynamic UI elements. These change whenever a particular event happens, e.g. when you reload a web page. It’s often harder for automated testing tools to identify these UI elements reliably. This is because identifiers that are robust for static UI elements (like the element ID) change all the time for dynamic UI elements. This is why you need to fall back on other identifiers for dynamic UI elements.

For web elements, Ranorex Studio uses an intelligent algorithm that recognizes when a UI element is dynamic. It ignores dynamic IDs and uses robust, static attributes instead. This means you should normally not need to find and replace dynamic IDs in your web repository items.

However, for desktop applications and mobile apps, you will need to deal with dynamic IDs manually. You can either replace them by hand in the RanoreXPaths of your repository items, or you can use RanoreXPath weight rules to optimize object recognition. We recommend the latter.

In this chapter, you’ll find out how attribute weights work and how you can change them with weight rules so that Ranorex Studio can reliably identify dynamic UI elements.

On this page, we summarize some of the key concepts necessary to understand the content on the other pages of this chapter.

In this chapter

    The object recognition process

    When tracking and identifying UI elements, Ranorex Studio categorizes them according to their purpose and to define their states.  When a UI element is dynamic, this is reflected in this categorization, i.e. one of its attributes has a dynamic value.

    The following image illustrates the categorization process.

    Assignment of technology-independent role

    Assignment of role-specific characteristics…

    …and attributes derived from these characteristics

    Assignment of one or more technology-specific capabilities…

    …and attributes derived from these capabilities


    This is explained in detail in

    Ranorex Studio advanced > UI elements > ⇢ Roles, capabilities, and more

    UI element identification with RanoreXPath

    Ranorex Studio uses RanoreXPath expressions to identify UI elements. These expressions are based on a set of hierarchical nodes and predicates. They reflect the categories assigned in the object recognition process. Therefore, a RanoreXPath expression may contain a dynamic attribute value to identify a UI element.

    The following image shows the structure of the RanoreXPath expression for the Exit button in the Ranorex Studio Demo Application. The expression uses a stable attribute value to identify the button.

    Basic structure: The RanoreXPath for an isolated UI element consists of three elements: an axis specifier, a node, and zero or more predicate(s)

    For the isolated Exit button, the axis specifier is /, the node is the role button, and the predicate consists of an attribute-value pair that uniquely identifies the button


    This is explained in detail in

    Ranorex Studio advanced > RanoreXPath > ⇢ RanoreXPath basics

    Which attributes does the RanoreXPath use?

    Ranorex Studio first categorizes UI elements and then generates a RanoreXPath expression for them based on these categories. However, while a UI element usually only has one role it can be assigned, there are many different attributes that derive from the element’s various categories and capabilities. Which of these attributes Ranorex Studio uses in the RanoreXPath expression to identify a UI element is not random. It is determined by so-called attribute weights.

    Let’s take a look at the Exit button in the Demo App again.

    Ranorex Studio assigns the technology-independent role button to the UI element

    Ranorex Studio recognizes that the UI element is a WinForms element and assigns the technology-specific capability WinForms to it

    The capability WinForms contains four Control attributes, from which Ranorex Studio chooses ControlName to use in the RanoreXPath expression to identify the UI element

    As mentioned above, Ranorex Studio doesn’t make this choice randomly. It uses the ControlName attribute because this attribute has the highest weight from all of the available ones.

    Attribute weights are important because they allow you to tell Ranorex Studio to use a stable attribute to identify a UI element. This is the solution to identifying dynamic UI elements reliably. The following pages of this chapter explain how to do this in detail.