Search code examples
windowsuipathsap-erpsap-guiuipath-studio

How to construct a selector based on dynamic ctrlid through UiPath?


This question have a reference to the following questions:

I am following the video SAP Automation with UiPath to automate logging in through a SAP client as a user with valid credentials.

Environment Details:

  • SAP Client: IDES ECC 6.0 incl. EhP7

  • Host machine: Intel Core i3 CPU with 64 bit - Windows 8 system.

Following the video I have a Attach Window activity which contains two activities as follows:

  • A Click Text of ClickType as CLICK_SINGLE
  • A Click Text of ClickType as CLICK_DOUBLE

The elements as identified by Selector Editor or UI Explorer are as follows:

<wnd ctrlid='76836616' />
<wnd ctrlid='100' title='SAP&apos;s Advanced Treelist' />

and

<wnd ctrlid='76836616' />
<wnd ctrlid='5002' title='myContainer' />
<wnd ctrlid='1008' />
<ctrl name='SAP_IDES' role='list item' />

As you can observe the ctrlid is same for both the elements but some how it is dynamic. However, the first couple of executions are perfecto.

The issue starts when trying to execute the workflow after a considerable amount of time have elapsed. I was facing an error as:

Error {"message":"Click Text 'SAPTreeList': Cannot find the UI element corresponding to this selector: <wnd ctrlid='90279688' /><wnd ctrlid='100' title='SAP&apos;s Advanced Treelist' />","level":"Error","logType":"Default","timeStamp":"2019-02-06T13:16:44.295729+05:30","fingerprint":"bec67d2a-14d1-4b93-ac06-03156aea69fe","windowsIdentity":"AtechM-03\\AtechM_03","machineName":"ATECHM-03","processName":"LearningUiPath","processVersion":"1.0.0.0","jobId":"e7f88d9e-e485-4eee-8a54-7450771238f3","robotName":"ATECHM_03","machineId":0,"fileName":"Main"}

So it was clear from the error message that the selector wasn't a valid selector.

Using Selector Editor and UI Explorer I found the ctrlid changes from '76836616' to '79865432'. So I tried to use partial selector. It is observed that UiPath randomly:

  • Identifies the element omitting <wnd ctrlid='76836616' /> but on execution shows error as:

    Error {"message":"Click Text 'SAPTreeList': Cannot find the UI element corresponding to this selector: <wnd omit:ctrlid='76836616' /><wnd ctrlid='100' title='SAP&apos;s Advanced Treelist' />","level":"Error","logType":"Default","timeStamp":"2019-02-27T11:59:39.2811258+05:30","fingerprint":"752fe27b-16f4-4e7b-95c0-f1e8a6b49e7b","windowsIdentity":"AtechM-03\\AtechM_03","machineName":"ATECHM-03","processName":"LearningUiPath","processVersion":"1.0.0.0","jobId":"b6ba7310-749c-4c28-a9d3-d1db0c6c7dec","robotName":"ATECHM_03","machineId":0,"fileName":"SAP_UserList_BOT"}
    
  • Identifies the element with wildcards in partial selector as <wnd ctrlid='7*' />. This works for 4-5 rounds of execution. But then '76836616' also changes to '88068312' where the execution fails.

So my question is how do I accomodate the dynamic ctrlid which changes time to time and is a mandatory selector for UiPath?


Solution

  • UI path has an anchor base activity that you can use when there is no reliable selector. It is a container for an anchor and an action acitivty that tries to locate your UI element by using other UI elements as anchors. You can you use both find element and find image activities as anchors.

    For example you can use a label for an input as anchor for your input as it is less likely for label to change.

    Keep in mind that anchor base acitivity does not work in the background.

    You can test efficiency / reliability of anchor base activity by trying to complete the challenge in this page. http://www.rpachallenge.com/ As in your case name and id attributes of inputs on rpachallenge page also changes on every submit.