2017-11-24 6 views
0

xpathに従ってGUIでオブジェクトを検索する方法を探しています。アプリケーションの識別の一部 私は次のようなxp​​athを持っています:PyWinAuto - XpathのようなID

./pane [0]/pane [0]/pane [1]/pane [0]/pane [1]/pane [0]/pane [編集] [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を使用しようとしました。

ですから、問題は、スタイルのようなxp​​athで要素へのパスを回復する方法はありますか?それはそうなっているはずです最初のケースでは

おかげ

+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) 
関連する問題