Search code examples
python-3.xpywin32pywinauto

Pywinauto - How to wait for TreeView till its visible


I want to wait for TreeView till it get visible by trying

evidence_treeview = context.new_evidence_window[u'TreeView']
 item = evidence_treeview.get_item([u'Evidence'])
 item.wait('visible', timeout=120)

but I am getting "AttributeError: '_treeview_element' object has no attribute 'wait' also when I am trying by this way wait_until(timeout=5, retry_interval=0.1, item.visible) I am getting error positional argument follows keyword argument


Solution

  • It's typical Python error. timeout=5 is a keyword argument because timeout is a keyword. All keyword arguments must be used after positional arguments (Python feature). In theory it could work so:

    wait_until(timeout=5, retry_interval=0.1, func=item.visible)
    

    But in practice it won't work because _treeview_element object doesn't have method .visible(). Correct usage is this method:

    item.ensure_visible()
    

    This method scrolls the tree view automatically to the target element. You don't need any special tricks or waits.