Depending on the technology of your application under test, your controls may have dynamic identifiers. You could of course adapt the path for each repository item, but you would have to do this every time a new item is added. The RxPathWeights plug-in enables you to filter out those identifiers and use an even better attribute to identify your application under test.
Have a look at our new blog post “Automated Testing and Dynamic IDs” for further information.
Set up your RxPathWeights configuration file (Ext-JS example)
The picture below shows the RanoreXPath of an ext-js input field on following ext-js example page.
You can see containers in the path which are identified by the id, beginning with “ext-comp-” and ending with a numeric value. These ids are dynamically generated and they may change.
We would like to set up a filter mechanism which should eliminate id attributes beginning with “ext-gen” or “ext-comp-” and ending with a numeric value.
- Open the Ranorex Spy and analyze you application under test
- Navigate to the element which has the dynamic identifier
- Write down the attribute name and the capability to which the attribute belongs to
- Download and extract the “RxPathWeights.zip” to following location (only needed for the system on which you will record your test scripts):
“C:\Documents and Settings\All Users\Application Data\Ranorex2\Plugins” (for Windows XP) or “C:\ProgramData\Ranorex2\Plugins” (for Vista, 7)
- Open the “Ranorex.Plugin.RxPathWeights.config” file in a text editor program
The configuration file consists of a rule element and an underlying condition element. The rule element enables you to change the weight of an attribute. By setting the weight to zero, the element will not be used in the RanoreXPath as an identifier anymore.
The condition element enables you to specify a rule for the attribute. In our sample, we would like to filter out ids which match following regular expression syntax
“(ext-gen|ext-comp-)[0-9]*”. (Read more about regular expression syntax here…)
<rxpathweights> <rule capability="webelement" attribute="id" setweight="0" conditionsoperator="or"> <condition source="self" attribute="id" match="(ext-gen|ext-comp-)[0-9]*" negate="false"/> </rule> </rxpathweights>
Save the config file and restart the Ranorex tools to load the RxPathWeights plug-in.
RxPathWeights plug-in documentation
- capability/attribute: define the target capability/attribute of the rule
- setweight: the weight to set if all the conditions evaluate to true
- conditionsoperator: defines the operator (“and” / “or”) that is used to combine the outcomes of multiple conditions in a rule
- source: can be self/parent/toplevel
- attribute: the attribute name to match. Can be different from the rule attribute name
- match: a regular expression. If you don’t specify the match value, the value of the attribute needs to be null to match
- negate: the outcome of the condition is the negated outcome of the match, e.g. if negate=”true” and the match fails, the condition evaluates to true
Latest posts by gherget (see all)
- Eliminate dynamic attributes in generated RanoreXPaths - July 15, 2010
- Defining execution parameters for your UI test - February 24, 2010
- Use the Ranorex Recorder to execute recurring tasks and simplify your everyday life - July 27, 2009