cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
soumiya
Helper I
Helper I

Dynamic Selector in web Automation

How to change the populate text of web page selector as the input field get changed as page get reloaded. Help out with any handling method of selectors to achieve the task

 

 

@selectors

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @soumiya

 

RPA challenge website is dynamic in a way that it moves the field elements every time it is loaded. But, the important to note there is that the other div of the element always contains consistent field labels ("Address", "First Name", "Company name", etc.). To target the correct element each time please customize the selector (as mentioned before) so that it looks for the field names and then the input field to populate it - for example like below:

  • For Address:
    •  adijain_0-1602694768320.png
    • First name selector: div:contains("First Name") > input
    • Similarly you can change the text inside contains operator to find any input field names you want. (Role in Company, Last Name, Company Name, Email, Phone Number, etc) 

    Hope it helps.

View solution in original post

15 REPLIES 15
PetrosF-MSFT
Microsoft
Microsoft

Hi @soumiya 

 

You could achieve that by manipulating the selector and making it more "generic".

 

First you have to inspect the selector extracted from multiple instances of the web page and determine what remains the same in every instance. Then, you can edit the CSS selector and modify the operator of the attribute that changes accordingly:

PetrosF-MSFT_0-1602501198223.png

 

Also, you could add an additional "fallback" selector by separating the two CSS selectors by a comma.

 

I hope the above helps!

 

Thanks for your reply...

But i am not still more clear i am trying to work on RPA challenge where the input text field keeps on changing in that class remains constant where as ordinal number gets changed what to do help me out with some solutions 

Hello @soumiya,

 

Since the class remains constant, you would need to customize the selector to only look for the class attribute value and deselect the remaining attributes (name, ordinal, innerText , etc.) to enable PAD to find the element consistently.

 

Please follow the steps below to edit a selector:

  • Search for the element that needs to be edited in the UI elements pane.

Capture.JPG

 

  • Right click on the element and go to edit selectors.

Capture2.JPG

 

  • Hover over the selector captured and right click on it to open the selector builder to edit it.

Capture3.JPG

 

  • This will open up the selector builder which can be used to easily customize the selector as appropriate. In your case you would need to only select the class attribute because it remains constant and deselect the ordinal and InnerText attributes as they are dynamic.

  Capture4.JPG

 

Further, if the above does not resolve your issue, please send us the selector path of the target element and the URL where it exists so that we can provide a solution. 

 

Thank you for trying Power Automate Desktop.

 

Thanks for your support,

 

I have tried the way that you had mentioned. Still the error comes. The selector error i have attached and also the url that i am trying to automate is www.rpachallenge.com. Thanks in advanced.

soumiya_0-1602563387255.png

 

Hello @soumiya

 

RPA challenge website is dynamic in a way that it moves the field elements every time it is loaded. But, the important to note there is that the other div of the element always contains consistent field labels ("Address", "First Name", "Company name", etc.). To target the correct element each time please customize the selector (as mentioned before) so that it looks for the field names and then the input field to populate it - for example like below:

  • For Address:
    •  adijain_0-1602694768320.png
    • First name selector: div:contains("First Name") > input
    • Similarly you can change the text inside contains operator to find any input field names you want. (Role in Company, Last Name, Company Name, Email, Phone Number, etc) 

    Hope it helps.

Thanks for your support @adijain 

It works

Hi @adijain 

I am facing an other issues on clicking the start button on RPA challenge website tried with all the selector possible still not able to achieve it.

body > app-root > div[Class="body row1 scroll-y"] > app-rpa1 > div[Class="row parent"] > div[Class="instructions col s3 m3 l3 uiColorSecondary"] > div:eq(5) > button[Class="waves-effect col s12 m12 l12 btn-large uiColorButton"][Type="submit"]

 

<button _ngcontent-c1 class="waves-effect col s12 m12 l12 btn-large uiColorButton">Start</button>

These are some selectors i tried but still not working

Hello @soumiya, Looks like that button is dynamic as well, please utilize the below selector to click on the start button:

adijain_0-1602789488183.png

 

Thanks for your support @adijain 

it works fine

Chandrasekaran1
New Member

Hi,

 

When i try to autmate the google search button,each time the selector generated is different . I tried to edit the selectors but not able to run.Can anyone tell me the solution.When i try to use press button ita not working.

 

Thanks in advance

 

 

 

 

 

FaerchDK
Frequent Visitor

Hi @adijain 

 

With help from this topic I was able to complete the RPA Challenge.

Now I'm trying to put that knowledge to use.

 

I have a dropdown menu where I need to select the item based on the installation number (Inst.:).

 

Dropdown menuDropdown menu

When I add the UI element I get this code: 

 

UI ElementUI Element

" > body[Class="minside"] > div[Class="page"] > header[Class="sidebar-navigation"] > div[Class="installation dropdown show"] > div[Class="dropdown-menu show"] > a[Class="dropdown-item"]:eq(9) > small"

 

If I understand this correctly it now picks the item based on a index number.

If I inspect the the element I can see that the installation number is located in the property "InnerText"

 

Inspect.jpg

 

So I tried to edit the code to this (removing the index number and adding innerText contains):

 

" > body[Class="minside"] > div[Class="page"] > header[Class="sidebar-navigation"] > div[Class="installation dropdown show"] > div[Class="dropdown-menu show"] > a[Class="dropdown-item"] > small[innerText*="103205"]"

 

But it isn't working and I'm kind of stuck.

 

Can you help?

 

Hello @adijain 

 

Is there a way to get an exact match instead of using contains? Sometimes the Power Automate will pick the first element that contains the text (as a subtext), but I only want to interact with the element with the exact match. 

 

Thank you!

Hi @akc, yes you can use WA_SimpleTextEqualsIgnoreCase for exact match instead of contains.

FaerchDK
Frequent Visitor

@adijain not to be pushy but can you help me with my issue?

liewcc
Regular Visitor

thks @adijain, just what I was looking for.

Is there a link with full list of all these special selector functions?

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Top Solution Authors
Top Kudoed Authors
Users online (3,113)