Dynamic or Variable Selectors in UiPath

    In this post, we would discuss how to use dynamic or parameterized selectors in UiPath.

    To explain parameterized selectors, we would use Automation Challenge Round 1 in the website by UiPath.

    The challenge is to create a workflow that can enter data to the form and submit. We have around seven fields on the web page and they all change their properties on each refresh. As you might already know, we can achieve this by indicating an anchor for each of these fields.

    So, I need to capture all the fields and its anchor and then design the workflow to enter details in all those fields.

    Let us capture the field First Name. The selector would look something like below.

    <html app='chrome.exe' title='Automation Challenge' />
    <webctrl aaname='First Name' tag='LABEL' />
    <nav up='1' />
    <webctrl tag='INPUT' />

    To identify the First Name text box, I used the anchor with aaname First Name.

    Now let us capture another element, say Email. The selector for email would look like below.

    <html app='chrome.exe' title='Automation Challenge' />
    <webctrl aaname='Email' tag='LABEL' />
    <nav up='1' />
    <webctrl tag='INPUT' />

    If we compare the selectors, the only change is the aaname. So if we parametrize, we can identify any element.

    To do this let us declare a variable fieldLabel.

    Now we have to use the variable fieldLabel inside the selector. We can do it like below.

    "<html app="" chrome.exe"" title="" Automation Challenge"" /><webctrl aaname=""" + fieldLabel + """ tag="" LABEL"" /><nav up="" 1"" /><webctrl tag="" INPUT"" />"

    See how we have introduced the variable fieldLabel in the selector. The entire string is in a single line and double quotes are escaped. The correct way to escape double-quotes in VB is by doubling the double-quotes.

    To use this parameterized selector, we need to enter the string into the Selector field under Target (Input >> Target >> Selector). Entering a value in the selector pop up window does not work.

    You can also save the string to a variable and use that variable as the selector.

    Now that we have a variable selector, you can enter the value in any field by changing the variable fieldLabel.

    A sample workflow is attached below. Follow the steps below to make the workflow work or you can modify it.

    • Open on the Chrome browser.
    • Navigate to the first challenge by clicking start.
    • Make the window active.
    • Run the workflow from UiPath.

    Related Articles

    Recent Articles

    How to fix Date Time data type issue in Blue Prism?

    Know more about the date time issue while using the code stage in Blue Prism and understand how to fix it by dealing with the UTC offset.

    How to deserialize JSON in UiPath?

    Tutorial on how to properly deserialize JSON with UiPath Web Activities. Explains the concept of JSON Array and JSON Object.

    Dynamic or Variable Selectors in UiPath

    Tutorial on how to use dynamic selectors in UiPath. Explains how to use variables in UiPath selectors.

    Change Case Excel Add-In

    Change Case Excel Add-In is a powerful Excel Add-In that can change the case of selected cells. With easy to use Keyboard shortcuts, perform case conversion in style.

    Blue Prism Video Tutorial

    A well-structured video tutorial on Blue Prism, which is the right starting point for your RPA career. #rpa #blueprism

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Stay on top - Get latest articles in your inbox