Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Match Rule best practices

Updated on May 26, 2022

To use Pega Robot Studio effectively, you must understand the application you are interrogating and automating. For matching, this means paying attention to where controls are used and when they match.

During interrogation, you should always check the object hierarchy after each transition (window created, screen changed, web page loaded) to make sure that a control is not matching a target that it should not.

Likewise, after a control is interrogated, examine the automatically created match rules to make sure they are appropriate. In particular, examine text and URL match rules to make sure that none of the content is dynamic.

For example, if the title of a window contains the account number the user has loaded, the default match rule contains that account number as well. You must modify the match rule to use a regular expression (regex) that excludes the account number so the form will match properly.

Regex mode in Text match rule
Match Rule Editor showing list of Modes with Regex highlighted.

Understanding match rules

You should understand how each match rule functions so you can determine when it should be used. For example, some match rules, such as the Position match rule, are more likely to break if applications change their layout dynamically. Likewise, if a web page changes its content depending on the user, the Element Index match rule may be more likely to break. For more detaill, see Match Rule types.

Testing matching in multiple scenarios

You should always run through multiple scenarios in an interrogation to test matching. Use a variety of test data to ensure that any presentation changes that occur due to different data are addressed.

When to use refresh matching

Refresh matching should be used with extreme caution and only when absolutely necessary. There are two situations in which refresh matching should never be used:

  • In a loop or to poll for the creation of a control, as this can severely degrade performance.
  • On a control that may be in the process of destruction, as this may lead to exceptions or deadlocks.

Refresh matching should be used in response to specific trigger events within a web page. Typically, DHTML updates a web page in response to user activity, such as clicking a link or a button. Automations should be organized so refresh matching is called in response to these actions. For example, web controls have an InnerHtmlChanged event that fires when JavaScript uses the InnerHtml property to update the contents of a web control. You can wait for the InnerHtmlChanged event to occur before calling refresh matching.

Refresh matching should always be called at the lowest level possible to ensure good performance. Because refresh matching can have negative side effects, it should only be used by advanced Robot Studio users with an in-depth understanding of HTML and JavaScript.

Use as few match rules as possible

You should use as few match rules as possible to create a unique match. Each match rule has a performance cost associated with it, however small. If Robot Studio only has to test one match rule rather than two, it will perform better. The number of match rules can be particularly important in large applications.

Multiple matches are not always bad

Robot Studio attempts to create the appropriate set of match rules for each object, which means adding match rules to a control until it matches uniquely. In some cases, multiple matches are not always bad. Consider a web page with two links that go to the same place, one in the header and one in the footer. Robot Studio automatically adds an Element Index Match Rule to distinguish between the two. However, these two targets are equivalent. You should remove redundant match rules in this circumstance so matching is as simple as possible.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us