我如何能得到复选框的状态 [英] How can i get the status of check box

查看:240
本文介绍了我如何能得到复选框的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得复选框的使用状态androidviewclient

I am trying to get the status of Checkbox using androidviewclient

lock = vc.findViewWithText('Lock SIM card')
if (lock.isChecked()):
    print "Enabled"
else:
    print "Disabled"

这总是返回False。

this always returns False .

有谁能够告诉我怎么去复选框的状态

can anybody tell me how to get the status of checkbox

推荐答案

这是因为锁是不ckeckbox。锁是包含锁定SIM卡文本视图。
您需要使用hierarchyviewer或uiautomatorviewer看到UI的布局。

That's because lock is not the ckeckbox. Lock is the text view containing "Lock SIM card". You need to use hierarchyviewer or uiautomatorviewer to see the layout of the UI.

用户界面看起来是这样的:

The UI looks something like:

(0) Linear layout
    (1) Relative layout
        (0) TextView "Lock SIM card"
        (1) TextView "Require PIN to use phone"
    (2) Linear layout
        (0) CheckBox

所以,你需要做的是这样的:

So you need to do something like:

linear_layout = lock.parent.parent
check_box = linear_layout.children[2].children[0]

这不是直线前进,但我用这个在过去和合作。
请注意,我用的是ViewClient版本是2.3。现在,它已经发展到4 +。

It's not straight forward, but I used this in the past and worked. Please note that the ViewClient version that I used was 2.3. Now it has evolved to 4+.

这篇关于我如何能得到复选框的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆