Search code examples
pythonautomationpywinauto

Pywinauto how do I get the list of returned elements


I'm using a WPF application that has custom stack panel, which is basically a list. The item in the list is exactly the same so I'm not able to select a specific text to uniquely identify the elements. And some other values such as time are dynamic.

Is there a way for me to get the list of elements returned. I know it's possible because the error was thrown, ElementAmbiguousError state the count.

If I could do that, then from that list I can use the index and validate what I need.


Solution

  • You can add found_index=0 or other index to the window specification object. This is the first way to disambiguate the search.

    Also there are methods .children() and .descendants() with additional params like control_type or title (as I remember title should work), but some window specification params are not supported in these methods.