2017-11-24 19 views
0

xpath에 따라 GUI에서 오브젝트를 검색하는 방법을 찾고 있습니다. 응용 프로그램 식별 부분 다음과 같이 xpath 있습니다 :PyWinAuto - 식별과 같은 Xpath

./pane [0]/pane [0]/pane [1]/pane [0]/pane [1]/pane [0]/pane [ 0]/창 [0]/텍스트 [0]/편집 [0]

이것은 (내가 거기에 문제가없는 경우) 응용 프로그램 요소 트리에서 선택한 EDIT를 가리 킵니다. enter image description here

은 내가 재귀 함수는 현재에 의해 쓰여진이없는이

#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를 사용하려고하지만, 어쩌면 내가 잘못된 길을 갈거야.

그래서 질문은 스타일과 같은 xpath에서 요소 경로를 복구하는 방법이 있습니까? 그렇게 보여야 첫 번째 경우를 들어

감사

+0

내 답변이 도움이 있습니까? –

답변

0

: 세 번째 경우를 들어

first = top.child_window(control_type="Pane", depth=2) 
# a bit confusing, will bind to depth=1 in future major release. 

네, ctrl_index 다른 기준에 따라 필터링하기 전에 사용됩니다. 먼저 검색 기준을 적용한 다음 작은 필터링 목록에서 선택해야하는 경우 found_index에 적합한 다른 매개 변수가 있습니다.

너무 변경해야합니다 :

third = second.child_window(control_type="Pane", found_index=1)