我正在尝试获取本机应用程序中切换开关的状态。
这是交换机本身的查询,当ON时:
query "Switch id:'quadrant_buzz'"
及其结果
[
[0] {
"class" => "android.widget.Switch",
"tag" => nil,
"description" => "android.widget.Switch{29ddf658 VFED..C. ........ 877,0-1017,81 #7f10017f app:id/quadrant_buzz}",
"id" => "quadrant_buzz",
"text" => "",
"visible" => true,
"rect" => {
"height" => 81,
"width" => 140,
"y" => 1303,
"x" => 877,
"center_x" => 947,
"center_y" => 1343
},
"enabled" => true,
"contentDescription" => nil
}]
这是开关关闭时的查询结果:
[
[0] {
"class" => "android.widget.Switch",
"tag" => nil,
"description" => "android.widget.Switch{29ddf658 VFED..C. ........ 877,0-1017,81 #7f10017f app:id/quadrant_buzz}",
"id" => "quadrant_buzz",
"text" => "",
"visible" => true,
"rect" => {
"height" => 81,
"width" => 140,
"y" => 1213,
"x" => 877,
"center_x" => 947,
"center_y" => 1253
},
"enabled" => true,
"contentDescription" => nil
}]
我不确定如何检查它的开/关状态。当我点击/触摸开关时,返回的查询中没有任何变化。我看到的唯一区别是居中。
卡拉巴什阿皮有什么东西吗?
感谢
在Android开发人员上查找Switch小部件的文档,方法是"isChecked"。http://developer.android.com/reference/android/widget/Switch.html
因此,您可以通过调用在Calabash中找到此值
query("Switch id:'quadrant_buzz'", :isChecked)
您也可以使用just:check-in Calabash。
isChecked有效。
irb(main):001:0>查询("android.widget.Switch",:isChecked)[[0]true]