Pywinauto如何获取返回元素的列表 [英] Pywinauto how do I get the list of returned elements

查看:786
本文介绍了Pywinauto如何获取返回元素的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有自定义堆栈面板的WPF应用程序,该面板基本上是一个列表.列表中的项目完全相同,因此我无法选择特定文本来唯一标识元素.时间等其他一些值是动态的.

有没有办法让我获取返回的元素列表.我知道这是可能的,因为抛出了错误,ElementAmbiguousError声明了计数.

如果我可以这样做,那么我可以从该列表中使用索引并验证我需要的内容.

解决方案

您可以将found_index=0或其他索引添加到窗口规范对象.这是消除搜索歧义的第一种方法.

也有方法.children().descendants()带有其他参数,例如control_typetitle(我记得title应该可以工作),但是这些方法不支持某些窗口规范参数.

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.

解决方案

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.

这篇关于Pywinauto如何获取返回元素的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆