3

Hello I have following information about my UI and TreeView item in on of the windows:

>>> x.dump_tree()
Control Identifiers:

TreeView - ''    (L662, T453, R1022, B651)
['', 'TreeView']
child_window(auto_id="1000", control_type="Tree")
   |
   | TreeItem - 'Program files (32 bit)'    (L697, T455, R822, B473)
   | ['TreeItem', 'Program files (32 bit)', 'Program files (32 bit)TreeItem', 'TreeItem0', 'TreeItem1']
   | child_window(title="Program files (32 bit)", control_type="TreeItem")
   |
   | TreeItem - 'Program files (64 bit)'    (L697, T473, R822, B491)
   | ['Program files (64 bit)', 'TreeItem2', 'Program files (64 bit)TreeItem']
   | child_window(title="Program files (64 bit)", control_type="TreeItem")
   |
   | TreeItem - 'Sample code'    (L697, T491, R782, B509)
   | ['Sample codeTreeItem', 'TreeItem3', 'Sample code']
   | child_window(title="Sample code", control_type="TreeItem")
   |    |
   |    | TreeItem - 'JSP & Java'    (L716, T509, R790, B527)
   |    | ['JSP & JavaTreeItem', 'TreeItem4', 'JSP & Java']
   |    | child_window(title="JSP & Java", control_type="TreeItem")
   |    |
   |    | TreeItem - 'C#.NET'    (L716, T527, R768, B545)
   |    | ['C#.NET', 'TreeItem5', 'C#.NETTreeItem']
   |    | child_window(title="C#.NET", control_type="TreeItem")
   |    |
   |    | TreeItem - 'PHP'    (L716, T545, R748, B563)
   |    | ['PHP', 'TreeItem6', 'PHPTreeItem']
   |    | child_window(title="PHP", control_type="TreeItem")
   |
   | TreeItem - 'C Interface Files (32 bit)'    (L697, T563, R838, B581)
   | ['C Interface Files (32 bit)', 'TreeItem7', 'C Interface Files (32 bit)TreeItem']
   | child_window(title="C Interface Files (32 bit)", control_type="TreeItem")
   |
   | TreeItem - 'C Interface Files (64 bit)'    (L697, T581, R838, B599)
   | ['C Interface Files (64 bit)', 'TreeItem8', 'C Interface Files (64 bit)TreeItem']
   | child_window(title="C Interface Files (64 bit)", control_type="TreeItem")
   |
   | TreeItem - 'Partner Sourced Data Server'    (L697, T599, R873, B617)
   | ['Partner Sourced Data ServerTreeItem', 'Partner Sourced Data Server', 'TreeItem9']
   | child_window(title="Partner Sourced Data Server", control_type="TreeItem")
>>> y = x.get_item('\\Program files (32 bit)')
>>> y
<uia_controls.TreeItemWrapper - 'Program files (32 bit)', TreeItem, 1916753231443648783>
>>> dir(y)
['__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__' , '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_abc_cache', '_abc_negative_cache', '_abc_negative_cache_version', '_abc_registry', '_as_parameter_', '_cache', '_calc_click_coords', '_control_types', '_create_wrapper', '_element_info', ' _needs_image_prop', '_scroll_types', '_select', 'actions', 'appdata', 'automation_id', 'backend', 'can_be_label', 'can_select_multiple', 'capture_as_image', 'children', 'children_texts', 'class_name', 'click_input', 'client_to_screen', 'close', 'collapse', 'control_count', 'cont rol_id', 'descendants', 'double_click_input', 'drag_mouse_input', 'draw_outline', 'element_info', 'ensure_visible', 'expand', 'friendly_class_name', 'friendlyclassname', 'get_child', 'get_expand_state', 'get_properties', 'get_selection', 'get_show_state', 'handle', 'has_keyboard _focus', 'has_title', 'iface_expand_collapse', 'iface_grid', 'iface_grid_item', 'iface_invoke', 'iface_item_container', 'iface_range_value', 'iface_scroll', 'iface_scroll_item', 'iface_selection', 'iface_selection_item', 'iface_table', 'iface_table_item', 'iface_text', 'iface_to ggle', 'iface_transform', 'iface_transformV2', 'iface_value', 'iface_virtualized_item', 'iface_window', 'invoke', 'is_active', 'is_checked', 'is_child', 'is_collapsed', 'is_dialog', 'is_enabled', 'is_expanded', 'is_keyboard_focusable', 'is_maximized', 'is_minimized', 'is_normal' , 'is_selected', 'is_selection_required', 'is_visible', 'iter_children', 'iter_descendants', 'legacy_properties', 'maximize', 'menu_select', 'minimize', 'move_mouse_input', 'parent', 'press_mouse_input', 'process_id', 'rectangle', 'ref', 'release_mouse_input', 'restore', 'right_ click_input', 'root', 'scroll', 'select', 'selected_item_index', 'set_focus', 'sub_elements', 'texts', 'top_level_parent', 'type_keys', 'verify_actionable', 'verify_enabled', 'verify_visible', 'wait_for_idle', 'was_maximized', 'wheel_mouse_input', 'window_text', 'windowclasses',  'writable_props']

It seems that all possible control methods are allowed only if Desktop is active ( computer is not locked or RDP session is active)

Is there any way to workarround this with methods that can be used while the desktop is locked ?

Extra info: Tthe process is started as admin(python process too) and I've connected to the process using connect method. Backend of the app is uia

Python version: 3.7 , pywinauto 0.6.5

I'm attching UI screenshot for more clarification: enter image description here

Here is my code that I use but it works only if desktop is active:

def click_tree_button(app, window, button, timeout=DEFAULT_TIMEOUT_MINI):
    "Add descr. here"
    starttime = time()
    while time() - starttime < timeout:
        try:
            app.top_window()
            app.window(title_re=window).child_window(control_type="Tree").get_item('\\' + button).select().type_keys('{SPACE}')
            return
        except (pywinauto.findwindows.ElementNotFoundError,
                pywinauto.findbestmatch.MatchError):
            sleep(0.5)
    raise Exception("Cannot click '{}' tree button on '{}' screen".format(button, window))
  • Maybe [this article](https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html) will help you to keep remote machine unlocked. – Vasily Ryabov Oct 20 '18 at 14:37
  • Also waiting could be much simpler: `app.window(title_re=window).wait('ready', timeout=timeout)` and/or `app.window(title_re=window).child_window(control_type="Tree").wait('ready', timeout=timeout)` without your own while loop. – Vasily Ryabov Oct 20 '18 at 14:44
  • See https://pywinauto.readthedocs.io/en/latest/wait_long_operations.html – Vasily Ryabov Oct 20 '18 at 14:44
  • Is it helped to resolve your problem? – Vasily Ryabov Oct 23 '18 at 09:07
  • The problem is that I power on the remote computer from a vSphere using its API and the user is automatically logged in. Then my test is automatically started but due to non active desktop some of the steps fail. So I'm searching for workaround how to skip this "Visible" desktop clicks and pressing buttons. Is there way to use send_text or .click() methods on treeItem elements ? About second part - thanks I will check it and refactor my functions - it seems that I missed the part with in-build timeout module. – Andro Vesselinov Oct 24 '18 at 16:31
  • It's still possible to have active desktop when you use VNC server software (I used TightVNC on my previous job). It may require to update video card drivers in case of black screen on client side because it provides non-virtual desktop (opposite to RDP). Also using RDP and then disconnecting may break active desktop. In this case you should reboot the PC or use workaround described above in the first comment. – Vasily Ryabov Oct 26 '18 at 10:29

0 Answers0