Ui-Path: How to handle dynamic web elements

user6071082 picture user6071082 · Jul 4, 2017 · Viewed 15.2k times · Source

I am new to UIPath tool. please accept my apologizes if it's a poor question.

I need to click\sendKeys a web element, which is totally a dynamic element. ID will keep change for everytime when loading the page.

Login 1: <span id="x58Sn0-cnt" class="z-tab-text" uipath_custom_id="8">Update</span>

Login 2: <span id="nT9Tn0-cnt" class="z-tab-text">Update</span>

Note:
Also we can't relay on class "z-tab-text" because so many other elements are sharing the same class.

thanks in advance. :)

Answer

brunoazev picture brunoazev · Jul 13, 2017

You may refer to the parent elements in order to get the right selector, for this you should be using the css-selector property instead of considering the id html attribute. For instance, let's suppose the dynamic element is always the first child of a div, then you could use:

<webctrl css-selector='div span:first-child'/>

The syntax for the css-selector property is the same as used in element selectors in CSS sheets for HTML files.

Just to comment, you can also find more tips and discussion in UiPathForum, which is full of knowledge and discussion about specific implementations on this tool.