Reputation: 59
I'm looking for way how to search objects in GUI according to xpath. part of identification of application I have xpath as follows:
./pane[0]/pane[0]/pane[1]/pane[0]/pane[1]/pane[0]/pane[0]/pane[0]/text[0]/edit[0]
This should (if i have no problem there) point to selected EDIT in application element tree.
I tried to use this xpath to identify items like this
#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)
I don't have recursive function written by now, but maybe I'm going the wrong way.
So the question is, is there any way how to recover path to element in xpath like style?
Thanks
Upvotes: 2
Views: 992
Reputation: 9991
For the first case it should look so:
first = top.child_window(control_type="Pane", depth=2)
# a bit confusing, will bind to depth=1 in future major release.
For third case yes, ctrl_index
is used before filtering by other criteria. If you need to apply search criteria first and then choose from small filtered list, there is another param suitable for your case: found_index
.
It should be changed so:
third = second.child_window(control_type="Pane", found_index=1)
Upvotes: 1