Link Search Menu Expand Document

RG-USG-002 Hardcoded Selector

Description

RG-USG-002 inspects the Target Selector attribute for any activity from the UiPath.Systems.Activites package. This rule reports on activities that have selector values that contain hardcoded selector strings.

Impact

Workflow Maintenance

Mitigation

Selector strings should not be hardcoded, they should be either dynamically generated or assigned by an Argument or Variable.

This allows selectors to be maintained from one location but utilised by multiple Activities without being re-defined. When a selector has to be changed, a single edit updates all referencing Activities.

Define and manage selector strings from a central location. Consider storing selectors in a file that is external to your workflows but is also packaged with your Library or Process. Code your workflows to load required selectors from that file into variables.

If you use Robotic Enterprise Framework, consider defining selectors in the “Data\Config.xlsx” spreadsheet. Record them in the constants worksheet or add additional selector worksheets to the workbook. Code your workflows to load required selectors from the worksheet into variables.

UiPath v2020.4 introduced Modern Design Experience where new automation activities utilise UI Descriptors to interact with UI elements. UI Descriptors are defined and managed from the Object Repository. The Object Repository ensures the management, reusability, and reliability of UI elements by capturing them as objects in a DOM-like repository, sharable across projects. It allows for creating and reusing UI taxonomies inside and across automation projects. It is recommended to enable and utilise Modern Design Experience when available.

Further Reading