Print Tree with return_structure reports an error

refering to issue #806 ::
I reinstalled rpaframework with version 2.1.1

python -m pip install rpaframework
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: rpaframework in c:\users\herbe\appdata\roaming\python\python311\site-packages (22.1.1)

Running the script which has been delivered with issue #806 I got the error:
ElementNotFound: Element not found with locator ‘return_structure=True’

the robot file

*** Settings ***
Library RPA.Windows
Library RPA.FileSystem
Library Collections
Library RPA.Browser.Selenium

*** Tasks ***
Get Entries From KeePass Group
[Setup] Windows Search KeePass 2

# Control KeePass window and log+print its element tree.
Control Window    subname:"- KeePass"
${structure} =    Print Tree    return_structure=${True}
Log To Console    ${structure}

# Get all secret groups matching criteria. (belonging to the accepted names list)
@{names} =    Create List    Test
@{groups} =    Create List
${elems} =    Get Elements    name:Database > type:TreeItemControl
FOR    ${elem}    IN    @{elems}
    ${status} =    Run Keyword And Return Status    Should Contain
    ...    ${names}    ${elem.name}
    IF    ${status}
        Append To List    ${groups}    ${elem}
    END
END

# Now print all the entries in every accepted group.
FOR    ${group}    IN    @{groups}
    Click    ${group}  # make sure to unfold the current group
    Log To Console    In group: ${group.name}
    # Note that the parent `path:` below is relative to the main window and not the
    #  group we're currently in. (as the entries are not listed inside the group
    #  itself in the element tree)
    ${elems} =    Get Elements    path:1|1|1|2|1 > type:ListItemControl
    FOR    ${elem}    IN    @{elems}
        Log To Console    Entry: ${elem.name}
    END
END

[Teardown]    Close Current Window

Hi, I was able to run the very same example just fine. Ensure you’ve got your env built correctly and that you’re using the latest rpaframework==22.2.2.

I am sorry but what have I done wrong ?
I updated rpaframewirk to 22.2.2 but the error is the same.
Here my Terminal soutput:

PS D:\RPA\KeeP> D:; cd ‘D:\RPA\KeeP’; & ‘C:\Users\Herbe\AppData\Local\robocorp\temp\4d65822107fcf16a\rf-ls-run\run_env_00_f7gvn6pn.bat’ ‘-u’ ‘c:\Users\Herbe.vscode\extensions\robocorp.robotframework-lsp-1.9.0\src\robotframework_debug_adapter\run_robot__main__.py’ ‘–port’ ‘49258’ ‘–no-debug’ ‘–pythonpath’ ‘d:\RPA\Course.’ ‘D:\RPA\Course\Listkee.robot’

Listkee

Get Entries From KeePass Group | FAIL |
ElementNotFound: Element not found with locator ‘return_structure=True’

Listkee | FAIL |
1 task, 0 passed, 1 failed

Output: D:\RPA\KeeP\output.xml
Log: D:\RPA\KeeP\log.html
Report: D:\RPA\KeeP\report.html
PS D:\RPA\KeeP> python -m pip show rpaframework
Name: rpaframework
Version: 22.2.2
Summary: A collection of tools and libraries for RPA
Home-page: https://rpaframework.org/
Author: RPA Framework
Author-email: rpafw@robocorp.com
License: Apache-2.0
Location: C:\Users\Herbe\AppData\Roaming\Python\Python311\site-packages
Requires: chardet, click, comtypes, cryptography, docutils, exchangelib, graphviz, holidays, htmldocx, hubspot-api-client, importlib-metadata, java-access-bridge-wrapper, jsonpath-ng, mss, netsuitesdk, notifiers, O365, oauthlib, openpyxl, pendulum, pillow, psutil, PyJWT, pynput-robocorp-fork, pyotp, pyperclip, PySocks, pywin32, pywinauto, PyYAML, requests, requests-oauthlib, robotframework, robotframework-pythonlibcore, robotframework-requests, robotframework-sapguilibrary, robotframework-seleniumlibrary, robotframework-seleniumtestability, rpaframework-core, rpaframework-pdf, rpaframework-windows, selenium, simple_salesforce, tenacity, tweepy, tzlocal, validators, xlrd, xlutils, xlwt
Required-by:
PS D:\RPA\KeeP>
PS D:\RPA\KeeP>

You are using python 3.11. Our current recommended python is still v3.9.13.

And that should be declared in your conda.yaml file, along with your other dependencies. And you should not have need to manually pip install things.

If you have not yet gone thru our courses, I recommend you to do so, see: RPA training courses and certifications | Robocorp documentation

Thank you for the information. I have gone thru the course part1 but needed now some work before I proceed.
I have created a new workspace and now I have python 3.9.13 and rpaframework 22.2.2
I am not allowed to send you the log as zip - sorry.
Now I got another error as you can see from the log.

PS D:\RSB> d:; cd ‘d:\RSB’; & ‘C:\Users\Herbe\AppData\Local\robocorp\temp\4d65822107fcf102\rf-ls-run\run_env_00_4ceof5lh.bat’ ‘-u’ ‘c:\Users\Herbe.vscode\extensions\robocorp.robotframework-lsp-1.9.0\src\robotframework_debug_adapter\run_robot__main__.py’ ‘–port’ ‘65311’ ‘–no-debug’ ‘–pythonpath’ ‘d:\RSB.’ ‘–report’ ‘NONE’ ‘–outputdir’
‘output’ ‘–logtitle’ ‘Task log’ ‘tasks.robot’

Tasks

Get Entries From KeePass Group …{0: [WindowsElement(item=<uiautomation.uiautomation.WindowControl object at 0x000001ED3E638C70>, locator=‘subname:“- KeePass” and type:WindowControl’, name=‘AutoDb.kdbx - KeePass’, automation_id=‘MainForm’, control_type=‘WindowControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=967, right=1637, top=319, bottom=844, width=670, height=525, xcenter=1302, ycenter=581)], 1: [WindowsElement(item=<uiautomation.uiautomation.PaneControl object at 0x000001ED3E638C40>, locator=‘subname:“- KeePass” and type:WindowControl > path:1’, name=‘’, automation_id=‘m_splitHorizontal’, control_type=‘PaneControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=975, right=1629,
top=399, bottom=814, width=654, height=415, xcenter=1302, ycenter=606), WindowsElement(item=<uiautomation.uiautomation.StatusBarControl object at 0x000001ED3E638760>, locator=‘subname:“- KeePass” and type:WindowControl > path:2’, name=‘’, automation_id=‘m_statusMain’, control_type=‘StatusBarControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=975, right=1629, top=814, bottom=836, width=654, height=22, xcenter=1302, ycenter=825), WindowsElement(item=<uiautomation.uiautomation.ToolBarControl
object at 0x000001ED3E638790>, locator=‘subname:“- KeePass” and type:WindowControl > path:3’, name=‘’, automation_id=‘m_toolMain’, control_type=‘ToolBarControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=975, right=1629, top=374, bottom=399, width=654, height=25, xcenter=1302, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.MenuBarControl object at 0x000001ED3E638BB0>, locator=‘subname:“- KeePass” and type:WindowControl > path:4’, name=‘’, automation_id=‘m_menuMain’, control_type=‘MenuBarControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=975, right=1629, top=350, bottom=374, width=654, height=24, xcenter=1302, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.TitleBarControl object at 0x000001ED3E638610>, locator=‘subname:“- KeePass” and type:WindowControl > path:5’, name=‘’, automation_id=‘’, control_type=‘TitleBarControl’, class_name=‘’, left=991, right=1629, top=322, bottom=350, width=638, height=28, xcenter=1310, ycenter=336)], 2: [WindowsElement(item=<uiautomation.uiautomation.PaneControl object at 0x000001ED3E638FD0>, locator=‘subname:“- KeePass” and type:WindowControl > path:1|1’, name=‘’, automation_id=‘1705398’, control_type=‘PaneControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=975, right=1629, top=399, bottom=744, width=654, height=345, xcenter=1302, ycenter=571), WindowsElement(item=<uiautomation.uiautomation.PaneControl object at 0x000001ED3E638E50>, locator=‘subname:“- KeePass” and type:WindowControl > path:1|2’, name=‘’, automation_id=‘592026’, control_type=‘PaneControl’, class_name=‘WindowsForms10.Window.8.app.0.30495d1_r6_ad1’, left=975, right=1629, top=748, bottom=814, width=654, height=66, xcenter=1302, ycenter=781), WindowsElement(item=<uiautomation.uiautomation.ThumbControl object at 0x000001ED3E8058B0>, locator=‘subname:“- KeePass” and type:WindowControl > path:2|1’, name=‘Ziehpunkt’, automation_id=‘’, control_type=‘ThumbControl’,
class_name=‘’, left=978, right=983, top=814, bottom=836, width=5, height=22, xcenter=980, ycenter=825), WindowsElement(item=<uiautomation.uiautomation.TextControl object at 0x000001ED3E805E20>, locator=‘subname:“- KeePass” and type:WindowControl > path:2|2’, name=‘Ready.’, automation_id=‘’, control_type=‘TextControl’, class_name=‘’, left=1116, right=1615, top=817, bottom=834, width=499, height=17, xcenter=1365, ycenter=825), WindowsElement(item=<uiautomation.uiautomation.ThumbControl object at 0x000001ED3E8055E0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|1’, name=‘Ziehpunkt’, automation_id=‘’, control_type=‘ThumbControl’, class_name=‘’, left=977, right=982, top=374, bottom=399, width=5, height=25, xcenter=979, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E8056D0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|2’, name=‘New Database’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=984, right=1007, top=375, bottom=397, width=23, height=22, xcenter=995, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E8055B0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|3’, name=‘Open Database’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1007, right=1030, top=375, bottom=397, width=23, height=22, xcenter=1018, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E805610>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|4’, name=‘Save Database’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1030, right=1053, top=375, bottom=397, width=23, height=22, xcenter=1041, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.SeparatorControl object at 0x000001ED3E805550>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|5’, name=‘’, automation_id=‘’, control_type=‘SeparatorControl’, class_name=‘’, left=1053, right=1059, top=374, bottom=399, width=6, height=25, xcenter=1056, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E805490>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|6’, name=‘Add Entry’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1059, right=1091, top=375, bottom=397, width=32, height=22, xcenter=1075, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.SeparatorControl object at 0x000001ED3E805520>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|7’, name=‘’, automation_id=‘’, control_type=‘SeparatorControl’, class_name=‘’, left=1091, right=1097, top=374, bottom=399, width=6, height=25, xcenter=1094, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E805580>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|8’, name=‘Copy User Name’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1097, right=1120, top=375, bottom=397, width=23, height=22, xcenter=1108, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E805670>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|9’, name=‘Copy Password’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1120, right=1143, top=375, bottom=397, width=23, height=22, xcenter=1131, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E8054F0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|10’, name=‘Open URL(s)’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1143, right=1175, top=375, bottom=397, width=32, height=22, xcenter=1159, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E8054C0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|11’, name=‘Copy URL(s)’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1175, right=1198, top=375, bottom=397, width=23, height=22, xcenter=1186, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E805430>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|12’, name=‘Perform Auto-Type’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1198, right=1221, top=375, bottom=397, width=23, height=22, xcenter=1209, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.SeparatorControl object at 0x000001ED3E8053D0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|13’, name=‘’, automation_id=‘’, control_type=‘SeparatorControl’, class_name=‘’, left=1221, right=1227, top=374, bottom=399, width=6, height=25, xcenter=1224, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object
at 0x000001ED3E8053A0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|14’, name=‘Find’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1227, right=1250, top=375, bottom=397, width=23, height=22, xcenter=1238, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E805370>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|15’, name=‘Find Entries’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1250, right=1279, top=375, bottom=397, width=29, height=22, xcenter=1264, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.SeparatorControl object at 0x000001ED3E805340>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|16’, name=‘’, automation_id=‘’, control_type=‘SeparatorControl’, class_name=‘’, left=1279, right=1285, top=374, bottom=399, width=6, height=25, xcenter=1282, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3E8052B0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|17’, name=‘Lock Workspace’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1285, right=1308, top=375, bottom=397, width=23, height=22, xcenter=1296, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.SeparatorControl object at 0x000001ED3E8052E0>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|18’, name=‘’, automation_id=‘’, control_type=‘SeparatorControl’, class_name=‘’, left=1308, right=1314, top=374, bottom=399, width=6,
height=25, xcenter=1311, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.ComboBoxControl object at 0x000001ED3E805310>, locator=‘subname:“- KeePass” and type:WindowControl > path:3|19’, name=‘’, automation_id=‘723094’, control_type=‘ComboBoxControl’, class_name=‘WindowsForms10.COMBOBOX.app.0.30495d1_r6_ad1’, left=1315, right=1436, top=375, bottom=398, width=121, height=23, xcenter=1375, ycenter=386), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC97F0>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|1’, name=‘File’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=981, right=1018, top=352, bottom=372, width=37, height=20, xcenter=999, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC96A0>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|2’, name=‘Group’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=1018, right=1070, top=352, bottom=372, width=52, height=20, xcenter=1044, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC9820>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|3’, name=‘Entry’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=1070, right=1116, top=352, bottom=372, width=46, height=20, xcenter=1093, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC97C0>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|4’, name=‘Find’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=1116, right=1158, top=352, bottom=372, width=42, height=20, xcenter=1137, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC9880>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|5’, name=‘View’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=1158, right=1202, top=352, bottom=372, width=44, height=20, xcenter=1180, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC98B0>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|6’, name=‘Tools’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=1202, right=1248, top=352, bottom=372, width=46, height=20, xcenter=1225, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuItemControl object at 0x000001ED3EDC98E0>, locator=‘subname:“- KeePass” and type:WindowControl > path:4|7’, name=‘Help’, automation_id=‘’, control_type=‘MenuItemControl’, class_name=‘’, left=1248, right=1292, top=352, bottom=372, width=44, height=20, xcenter=1270, ycenter=362), WindowsElement(item=<uiautomation.uiautomation.MenuBarControl object at 0x000001ED3EDC9AC0>, locator=‘subname:“- KeePass” and type:WindowControl > path:5|1’, name=‘Systemmenü’, automation_id=‘MenuBar’, control_type=‘MenuBarControl’, class_name=‘’, left=975, right=997, top=327, bottom=349, width=22, height=22, xcenter=986, ycenter=338), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3EDC9AF0>, locator=‘subname:“- KeePass” and type:WindowControl > path:5|2’, name=‘Minimieren’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1490, right=1537, top=320, bottom=350, width=47, height=30, xcenter=1513, ycenter=335), WindowsElement(item=<uiautomation.uiautomation.ButtonControl
object at 0x000001ED3EDC9B20>, locator=‘subname:“- KeePass” and type:WindowControl > path:5|3’, name=‘Maximieren’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1537, right=1583, top=320,
bottom=350, width=46, height=30, xcenter=1560, ycenter=335), WindowsElement(item=<uiautomation.uiautomation.ButtonControl object at 0x000001ED3EDC9970>, locator=‘subname:“- KeePass” and type:WindowControl > path:5|4’, name=‘Schließen’, automation_id=‘’, control_type=‘ButtonControl’, class_name=‘’, left=1583, right=1630, top=320, bottom=350, width=47, height=30, xcenter=1Get Entries From KeePass Group
| FAIL |
ElementNotFound: Element not found with locator ‘name:Database > type:TreeItemControl’------------------------------------------------------------------------------
Tasks | FAIL |
1 task, 0 passed, 1 failed

Output: D:\RSB\output\

You got this error as you Keepass does not have element called Database
image

Modify the code to suit your setup and it runs fine.
Need to change it code below to your situation:

${elems} =    Windows.Get Elements    name:Database > type:TreeItemControl
1 Like

Thank you for this remark.
I have changed it to the name of my database (AutoDb) and now it runs without error but also without any output of the groups and entries. I will try to understand your solution ann modify it to get the same results as my ronot does. The problem I had was that if the robot did loose the windows top level because I started the editor to look into the file with the output (by RPA.FileSystem) the robot did not work correct anymore. What has been changed that this will not happen with the new version. For me this was a test to see how influenced the robot is from outside events within the same system e.g popup of another application
I will come back after I can make your robot run correctly and then try to disturb by getting the top window.

If you need to switch between applications you probably need to do it

  1. Control Window Keepass
    1.1. Perform some actions
  2. Control Window Editor
    2.1. Perform some actions
  3. Control Window Keepass
    3.1. Perform some actions

If manually activate other windows I assume you will still have an issue of lost focus

It is not a switch inside robot. It is an event from outside robot which I can not influence

I just try to simulate this

How can I handle the result of “print Tree” ${structure} ?
FOR ${element} IN @{structure}
Log ${element}
END

is not working because I just get 0,1,…,9

Your robot is not considering a group under a group

path:1|1|1|1|1|1|4|1’, name=‘Network’,

Your if {Status} will not return True bevause the group name is not in the List so you should ask for False.

The Entries you will not find with
${elems} = Get Elements path:1|1|1|2|1 > type:ListItemControl
They are also not to find in the ${structure} (at least I can not find them)

Log that ${structure} (with Log Dictionary for eg.) and you’ll see its content unfold. Is a dictionary where 0, 1, 2, ..., N are the depth levels and their values are lists of the flattened elements on each of those levels.
To operate with such dictionaries, please consult the Collections library and search for dictionary.

For more info on Windows path-based automation please read in detail the following:

Thank you for your information.
I have changed your robot so far that ir will find something but it is not working correct.
Some groups are lost in ${groups}.
It starts that the “Print Tree” is not going to the depth of 16 which I have defined. It stops at depth 8 (I tried both max_depth and search_depth).
I can not upload the files to document my test.
The new version of the robot is:

*** Settings ***
Library RPA.Windows
Library RPA.FileSystem
Library Collections
Library String

*** Variables ***
*** Tasks ***
Get Entries From KeePass Group v3
[Setup] Windows Search KeePass 2

# Control KeePass window and log+print its element tree.
${Window} =    Control Window    subname:"- KeePass"
${structure} =    Print Tree    return_structure=${True} search_depth=16

Log     ${structure}
${all_k} =    Get Dictionary Keys    ${structure}
${all_v} =    Get Dictionary Values    ${structure}
${vlist}    Convert To List   ${all_v}
FOR    ${v1}    IN    @{vlist}
    Log    ${v1}  
    ${v1c} =    Convert To List    ${v1}           
    FOR    ${v1ce}    IN    @{v1c}
        Log    entry= ${v1ce}
        ${path} =    Replace String Using Regexp    ${v1ce.locator}    .*path   path
        Log To Console    name= ${v1ce.name} automation_id= ${v1ce.automation_id} path=${path} control_type= ${v1ce.control_type}
    END
END

# Get all secret groups matching criteria. (belonging to the accepted names list)
@{names} =    Create List    
@{groups} =    Create List
${elems} =    Get Elements    name:AutoDb > type:TreeItemControl
FOR    ${elem}    IN    @{elems}
    ${status} =    Run Keyword And Return Status    Should Contain
    ...    ${names}    ${elem.name}
    Log    status= ${status}
    Log    ${names}
    Log    ${elem.name}
    IF    ${status} == False
        Log    ${elem}     
        Append To List    ${groups}    ${elem}
    END
END
Log    ${groups}
# Now print all the entries in every accepted group.
Log    ALL Groups: ${groups}
FOR    ${group}    IN    @{groups}
    Click    ${group}  # make sure to unfold the current group
    Log    In group: ${group.name}
    # Note that the parent `path:` below is relative to the main window and not the
    #  group we're currently in. (as the entries are not listed inside the group
    #  itself in the element tree)

${elems} = Get Elements path:1|1|1|2|1 > type:ListItemControl

    ${elems} =    Get Elements    search_depth=1    root_element=${Window}    siblings_only=False

${elems} = Get Elements

    Log    ${elems}
    FOR    ${elem}    IN    @{elems}
        Log    Entry: ${elem.name}
    END
END

[Teardown]    Close Current Window

if you allow me to send you my keepass database it maybe is easier to communicate the problems.

Be careful with the spacing here: return_structure=${True} search_depth=16, as you need more than one space between the passed arguments and depth is a number, otherwise, you’d pass that entire string to the first argument in position. Also, can you point me to where on Print Tree have you seen such a search_depth parameter? (I see just max_depth)

&{tree} =    Windows.Print Tree    return_structure=${True}    max_depth=${16}
Log Dictionary    ${tree}

Please pay more attention to the docs, resources and the example provided.

Thank you for your help. I have sometimes problems with the one space and 4 space gap between arguments. I hope I get it better in the future.
But should not the interpreter or better the editor (VScode) already report an error ?

Another question about “Print Tree” is the result is a dictionary and I tried to extract from the dictionary the elements. But in using the element for a “Click” I get an error.
my Keyword for the extraction of elements is:

*** Keywords ***
Output Tree Items
[Arguments] ${Window}
# Control KeePass window and log+print its element tree.
${structure} = Print Tree ${Window} return_structure=${True} max_depth=16

Log     ${structure}
${elements}    Create List    
${all_k} =    Get Dictionary Keys    ${structure}
${all_v} =    Get Dictionary Values    ${structure}
${vlist}    Convert To List   ${all_v}
FOR    ${v1}    IN    @{vlist}
    Log    ${v1}  
    ${v1c} =    Convert To List    ${v1}           
    FOR    ${v1ce}    IN    @{v1c}
        Log    entry= ${v1ce}
        Append To List   ${elements}     ${v1ce}
        ${path} =    Replace String Using Regexp    ${v1ce.locator}    .*path   ${EMPTY}
        Log To Console    name= ${v1ce.name} automation_id= ${v1ce.automation_id} path=${path} control_type= ${v1ce.control_type}
    END
END
[Return]    ${elements}

the LOg with the error message is

KEYWORD RPA.Windows . Click ${group}

Documentation: Mouse click on element matching given locator.
Tags: action, mouse
Start / End / Elapsed: 20230316 11:44:25.214 / 20230316 11:44:25.226 / 00:00:00.012

11:44:25.217 INFO Getting element with locator: WindowsElement(item=<uiautomation.uiautomation.TreeItemControl object at 0x0000023E557BF5B0>, locator=‘subname:“- KeePass” and type:WindowControl > path:1 1 1 1 1 1 1’, name=‘Windows’, automation_id=‘’, control_type=‘TreeItemControl’, class_name=‘’, left=1018, right=1071, top=419, bottom=437, width=53, height=18, xcenter=1044, ycenter=428)

11:44:25.221 INFO Returning element: WindowsElement(item=<uiautomation.uiautomation.TreeItemControl object at 0x0000023E557BF5B0>, locator=‘subname:“- KeePass” and type:WindowControl > path:1 1 1 1 1 1 1’, name=‘Windows’, automation_id=‘’, control_type=‘TreeItemControl’, class_name=‘’, left=1018, right=1071, top=419, bottom=437, width=53, height=18, xcenter=1044, ycenter=428)

11:44:25.223 FAIL AttributeError: ‘TreeItemControl’ object has no attribute ‘robocorp_click_offset’

00:00:00.000KEYWORD BuiltIn . Log To Console /n**In group: ${group.name}

00:00:00.000KEYWORD ${elements} = Output Tree Items ${Window}

ListG.zip (1.5 KB)
Listkee.zip (811 Bytes)
AutoDb.zip (5.5 KB)
ListGroups.zip (628 Bytes)
Thank you for the possibility to send you the files involved:
ListGroups is the output of ListG.robot in case it keeps its top level on the display.
ListG.robot my version of the KeePass group and entrie list
AutoDb my Keepass database with the password “hhsem”
ListKee.robot is your version with some modifications causing the problem with “Click”

your version ListKee is not writing output in a file and is not working yet. So I can not disturb the robot during execution.
My disturbing which you can easy reproduce with ListG.robot is:

every time the KeePass becomes the Top window just click with the mouse into another window which will overlay the KeePass window. You will then see in the output file missing information. Irt should look the same as the file ListGroup which you can reproduce without disturbing KeePass to be the top window.

This test is just to find out what is to do in the robot to detect this problem (I can not see any error reporting) and how to recover from this situation.
Thank you so far for your help

You welcome and thank you for all the details!

  • 1:44:25.223 FAIL AttributeError: ‘TreeItemControl’ object has no attribute ‘robocorp_click_offset’ this clearly looks like a bug coming from our side and under our control; is it possible for you to submit the full log trace so I can understand why and where is this happening? (if you run in VSCode with Robocorp extension or with rcc, you should have a log.html file generated)
  • The top-window which gets out of focus issue is not under our control. Like you said, the app itself changes the returnable structure, which comes from how the uiautomation library we use interacts with Windows OS resources in order to retrieve the controls. As some controls will be displayed only when they get in focus or even accessed further (unfolding). (so this is a limitation where you need to continue to work with that app in focus to preserve the structure or re-initiate the flow each time you’re getting back to it)

Hello!
Before I tried to reproduce the problem some automatic update took place but the problem is still the same. How can I easy check which version is in use for the different components.
I send <ou the log and the task.robot which is the modified version of your robot
log.zip (96.6 KB)
tasks.zip (1.3 KB)