我正在使用android视图客户端来测试UI。我的层次结构看起来像(从android studio的监视器工具中看到):
我想要做的是掌握球,然后对其进行触控操作。
然而,我无法得到它。 我用过:
from com.dtmilano.android.viewclient import ViewClient
print(ViewClient(*ViewClient.connectToDeviceOrExit()).findViewByTag("ImageView")
) as my python script.
输出显示无(但显然图像中可以看到图像视图)。
我在这里做错了什么?
修改:
当我使用culebra -G并点击球时,我明白了:
no_id1 = vc.findViewByIdOrRaise(" id / no_id / 1") com_facebook_orca___id_back_button = vc.findViewByIdOrRaise(" com.facebook.orca:id / back_button")no_id3 = vc.findViewByIdOrRaise(" id / no_id / 3")no_id3 = vc.findViewWithTextOrRaise(u'高分') com_facebook_orca___id_high_score_text = vc.findViewByIdOrRaise(" com.facebook.orca:ID / high_score_text&#34) com_facebook_orca___id_high_score_text = vc.findViewWithTextOrRaise(u' 29')no_id5 = vc.findViewByIdOrRaise(" id / no_id / 5")no_id5 = vc.findViewWithTextOrRaise(u' Current Best') com_facebook_orca___id_best_score_text = vc.findViewByIdOrRaise(" com.facebook.orca:ID / best_score_text&#34) com_facebook_orca___id_best_score_text = vc.findViewWithTextOrRaise(U' 1') 这里没有imageview。
另外,当我查看ViewClient.findViewById(" com.facebook.orca:id / ball")时,我得到None。
修改2
这是dump -a
的输出查看[class = android.widget.FrameLayout index = 0 selected = false checked = false clickable = false package = com.facebook.orca text = long-clickable = false enabled = true bounds =((0,0),(1280,672)) content-desc = focusable = false focused = false uniqueId = id / no_id / 1 checkable = false resource-id = password = false class = android.widget.FrameLayout scrollable = false] parent =无
查看[class = android.widget.ImageButton index = 0 selected = false NAF = true clickable = true package = com.facebook.orca text = long-clickable = false enabled = true bounds =((0,25),(64,89))content-desc = focusable = true focused = false uniqueId = id / no_id / 2 checkable = false resource-id = com.facebook.orca:id / back_button password = false class = android.widget.ImageButton checked = false scrollable = false]
parent = android.widget.FrameLayout查看[ class = android.widget.TextView index = 1 selected = false checked = false clickable = false package = com.facebook.orca text =高分 long-clickable = false enabled = true bounds =((1202,35),(1270,51)) content-desc = focusable = false focused = false uniqueId = id / no_id / 3 checkable = false resource-id = password = false class = android.widget.TextView scrollable = false]
parent = android.widget.FrameLayout查看[ class = android.widget.TextView index = 2 selected = false checked = false clickable = false package = com.facebook.orca text = 29 long-clickable = false enabled = true bounds =((1226,51),(1246,76))content-desc = focusable = false focused = false uniqueId = id / no_id / 4 checkable = false resource-id = com.facebook.orca:id / high_score_text password = false class = android.widget.TextView scrollable = false]
parent = android.widget.FrameLayout查看[ class = android.widget.TextView index = 4 selected = false checked = false clickable = false package = com.facebook.orca text = Current Best long-clickable = false enabled = true bounds =((591,95),(689,116)) content-desc = focusable = false focused = false uniqueId = id / no_id / 5 checkable = false resource-id = password = false class = android.widget.TextView scrollable = false]
parent = android.widget.FrameLayout查看[ class = android.widget.TextView index = 5 selected = false checked = false clickable = false package = com.facebook.orca text = 1 long-clickable = false enabled = true bounds =((612,116),(667,233))content-desc = focusable = false focused = false uniqueId = id / no_id / 6 checkable = false resource-id = com.facebook.orca:id / best_score_text password = false class = android.widget.TextView scrollable = false]
父= android.widget.FrameLayout
答案 0 :(得分:0)
我猜图像上的标记不是ImageView
。
在您的Android应用上使用View.setTag()设置标记,但我认为您不需要它。
根据您的层次结构,您可以使用ViewClient.findViewById("com.facebook.orca:id/ball")
来获取对此类视图的引用。
我还建议您使用culebra -G
(请参阅Culebra GUI),然后触摸球图像,culebra将生成正确的线条以查找视图并触摸它。