Windows App Automation

Hi,
I have tried to create a robot with the following scenario:
I have an excel file with two columns: 1.Username and 2.Role
I have created simple Windows application with one input field for username, a drop down menu(where the user can select role), and checkboxes to check the permissions.
Until this moment, I have succeeded to get the usernames from the excel file and insert them in the input field.
I need help with choosing the exact option from the dropdown for each of the usernames and check different checkboxes. For example, if User1 is inserted, Front Office should be selected, and View account info checked, if User11 is inserted, Back Office should be selected from the dropdown and create account should be checked, etc.
I cannot find any regular if statement for this part of the scenario, except for Run Keyword if/Run Keyword unless, which I do not find useful in my case.
Please checkout the screenshot and the code below, and let me know if there is any solution. There is also a screenshot of the excel file data in comment.
Thanks!

C O D E:

*** Settings ***
Documentation An example robot.
Library RPA.Desktop.Windows
Library RPA.Excel.Files

*** Keywords ***
Open Application and type username using data from excel file
Open Workbook WindowsApp_Data.xlsx
{usernames}= Read Worksheet As Table header=True {roles}= Read Worksheet As Table header=True
Close Workbook
FOR {username} {role} IN ZIP @{usernames} @{roles}
Open Application and type name {username} {role}
END

*** Keywords ***
Open Application and type name
[Arguments] {username} {role}
Open From Search WindowsFormsApp1.exe Demo Windows Forms App
sleep 5
Type keys {username}\[Username] Mouse click name:View avvount info Mouse click name:Open sleep 3 Mouse click name:{role}[Role]
Mouse click name:Save
Mouse click name:OK
[Teardown] Mouse click name:Close

*** Tasks ***
Open Application and type username using data from excel file
Open Application and type name
Log Done.

Hi!

Have you checked out https://robocorp.com/docs/development-howtos/windows/how-to-find-user-interface-elements-using-locators-and-keyboard-shortcuts-in-windows-applications#inspecting-windows-applications-with-accessibility-insights

It presents things in recommended order as well, with Windows id:s being the recommended way, and image based locators as a fallback.

As for the branching/if:s, you could open the dropdown for each row, and as the next step interact with the dropdown element that matches the role. You can place the locator aliases in a dictionary to avoid If:s

For the checkboxes you could apply the same approach if there is only one box per role that needs ticking, and perhaps you could place them as a list of locators to click in case of multiple ones. And then iterate over the list to click each necessary nox

Does Desktop.Windows support image-based locators? I do not see “alias” within WINDOWS_LOCATOR_STRATEGIES. I try to do a simple mouse click directly in python using a locator like below:
win.mouse_click(“alias:TestApp.Menu”)

Have you tried the method outlined under the “Image template matching” section of this page? https://robocorp.com/docs/developer-tools/robocorp-lab/locating-and-targeting-UI-elements

Yes, I saw it. I have defined locator using Lab and pasted in into task’s code as shown earlier but it gives me

Could not find unique element for ‘alias:TestApp.Menu’

From documentation I get impression that aliases work in notebook mode, from your example seems you are using python. One way is to give image path as input not alias?

And how shall I do it? Which WINDOWS_LOCATOR_STRATEGIES to use? Your documentation needs some investments…