我正在寻找如何根据xpath在GUI中搜索对象的方法。申请鉴定的一部分 我有xpath如下:
./窗格[0] /窗格[0] /窗格[1] /窗格[0] /窗格[1] /窗格[0] /窗格[0] /窗格[0] /文本[0] /编辑[0]
这应该(如果我没有问题)指向应用程序元素树中的选定EDIT。
我尝试使用此xpath来识别此类项目
#app is the application under test, this is working correctly
top = app.top_window()
first = top.child_window(control_type="Pane")
print first #here is first problem: This will find all the child_windows, no just the direct children, without depth search (is it possible to just search particular direct childrens, without deeper search?)
first = top.child_window(control_type="Pane", ctrl_index=0)
#this is much better
second = first.child_window(control_type="Pane", ctrl_index=0)
print second
#this is working, i'm looking for [0] indexed Pane under first found element
third = second.child_window(control_type="Pane", ctrl_index=1)
print third
# we have another problem , the algorithm is depth first, so ctrl_index=1 is not referencing to '2nd child of element named second', but instead to the first element of first pane, founded under 2nd element. (I'm looking for wide first algorithm)
我现在没有编写递归函数,但也许我的方法错了。
所以问题是,有没有什么方法可以像样式一样恢复xpath中的元素路径?
由于