Attribute weights are integer values assigned to UI element attributes. They control which attributes Ranorex Studio uses in RanoreXPath expressions to identify UI elements.
On this page, we explain attribute weights and how you can access their configuration dialog.
In this chapter
What are attribute weights?
To reliably identify UI elements, Ranorex Studio can choose from more than 600 attributes that are derived from two categories: role-specific characteristics and technology-specific capabilities.
Aside from an attribute name (e.g. ControlName) and an element-specific attribute value (e.g. ‘RxButtonExit’), each attribute also has a weight value. This weight value is an integer between 0 and 200.
When generating a RanoreXPath for a UI element, Ranorex Studio uses the attribute with the highest weight to identify the UI element. Attributes with weights below 100 (i.e. starting from 99) are ignored for RanoreXPath generation. (They may instead be used for automatic name generation for repository items).
Therefore, from the attributes in the image above, Ranorex Studio would use ControlName to identify the Exit button in the Ranorex Studio Demo Application because it has the highest attribute weight at 150.
Ranorex Studio contains default attribute weights for all attributes. These are based on testing and experience and work well in most cases. However, in some cases, you may need to fine-tune them. Reliably identifying UI elements with dynamic attributes is one such case. Below, we explain where you can find the dialog to edit attribute weights. On the next page of this chapter, we then use an example to explain how to apply new attribute weights in practice.
Configuration dialog for attribute weights
To open the dialog for configuring attribute weights, do one of the following:
In Ranorex Studio or Ranorex Spy, click Settings > Advanced > Edit attribute weights….
In Ranorex Spy under Browser & Results, select an element in the element tree and under Overview, click Edit path weights…
The configuration dialog opens:
Overview of all currently existing attribute weight rules and buttons to add, delete, and disable them.
Attribute weights are organized according to weight rules. Weight rules are where you can change the weights of individual attributes. You can also apply rule conditions to control which UI elements a weight rule (and therefore, the weight adjustment) affects. We explain this on the next page.
Button to restore the default attribute weight values
Fields to name the rule and to control which attribute’s weight you want to change and whether conditions should apply
Link to display the attribute weight values for this rule (see image below)
Fields to create and edit rule conditions
Overview of all attributes and their weights for a rule