cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HellitonWoo
Regular Visitor

Dynamic Selector (variable in selector) in Desktop Automation

Hi fellow users,

 

Has anyone found a solution to use "variable" in the selector?

For instance, the application may have a table, to click and type into the table, I need the index of the row and column.

Thus it would be nice to create a variable to help to point to the row that I'm about the click.

 

I've tried referring the variable using %var%, but it won't work.

 

BR

Helliton

1 ACCEPTED SOLUTION

Accepted Solutions
adijain
Microsoft
Microsoft

Hello @HellitonWoo,

 

Variables can be parsed in CSS and UI selectors in Power Automate Desktop. To do that please follow the steps below:

  • Search for the element that needs to be edited in the UI elements pane, right click on the element and go to edit selectors.
  • Navigate to the selector builder which can be used to easily customize the selector and click on "custom" toggle button.
    • adijain_4-1602615199374.png
  • Now for your case you would need to parse the variable %var_row% in the table selector attribute. e.g. shown in the screenshot below:
    • adijain_6-1602615373965.png

       

Hope the above helps. Please let us know the target selector path and variable name to be parsed if you encounter any issues. Thanks!  

 

 

 

View solution in original post

7 REPLIES 7
adijain
Microsoft
Microsoft

Hello @HellitonWoo,

 

Variables can be parsed in CSS and UI selectors in Power Automate Desktop. To do that please follow the steps below:

  • Search for the element that needs to be edited in the UI elements pane, right click on the element and go to edit selectors.
  • Navigate to the selector builder which can be used to easily customize the selector and click on "custom" toggle button.
    • adijain_4-1602615199374.png
  • Now for your case you would need to parse the variable %var_row% in the table selector attribute. e.g. shown in the screenshot below:
    • adijain_6-1602615373965.png

       

Hope the above helps. Please let us know the target selector path and variable name to be parsed if you encounter any issues. Thanks!  

 

 

 

@adijain 

Thanks for the answer!

 

This is the selector, and the way it worked exactly as explained:

window[Class="#32770"][Name="New Invoice"] > list[Class="SysListView32"] > listitem[Id="ListViewItem-%row_nr%"] > text[Id="ListViewSubItem-%col_nr%"]

 

 

Anonymous
Not applicable

Hi

 

I struggled a bit with using a dynamic selector as well untill I understood that in order for it to work, "Custom" HAS to be toggled 🙂 

 

Best Regards

Mikkel

Kevin77
New Member

Hi Guyz,

 

Please help to solve this dynamic selector div[Id="screenarea2.B10"].

Kevin77_0-1625746315237.png

 

Hi @Kevin77, you can customize the selector to this: 

iframe[Id="application-Shell-startGUI"] > div[Id^="screenarea2"]

 

this can be done either by hitting the custom button or changing the div's Id attribute operator to "Starts with"

RiiG
Frequent Visitor

Hi

 

can variables be used in attribute names?

this didn't work.....

Screenshot 2022-06-30 084614.png

RiiG
Frequent Visitor

is there any way to remove the quotes from around the variable in the selector above? 

Helpful resources

Announcements
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 Kudoed Authors
Users online (4,825)