Calabash:获取拨动开关的状态
Calabash: Get state of toggle switch
我正在尝试获取本机应用程序中切换开关的状态。
这是开关本身的查询,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
}]
我不确定如何检查其 on/off 状态。当我 tap/touch 切换时,返回的查询没有任何变化。我看到的唯一区别是 center-y。
Calabash Api 里有什么东西吗?
谢谢
在 Android 开发人员中查找 Switch 小部件的文档,它是方法 "isChecked"。 http://developer.android.com/reference/android/widget/Switch.html
因此您可以通过调用
在 Calabash 中找到这个值
query("Switch id:'quadrant_buzz'", :isChecked)
您也可以在 Calabash 中使用 :checked。
isChecked 有效。
irb(main):001:0> query("android.widget.Switch",:isChecked)
[
[0] true
]
我正在尝试获取本机应用程序中切换开关的状态。
这是开关本身的查询,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
}]
我不确定如何检查其 on/off 状态。当我 tap/touch 切换时,返回的查询没有任何变化。我看到的唯一区别是 center-y。
Calabash Api 里有什么东西吗?
谢谢
在 Android 开发人员中查找 Switch 小部件的文档,它是方法 "isChecked"。 http://developer.android.com/reference/android/widget/Switch.html
因此您可以通过调用
在 Calabash 中找到这个值query("Switch id:'quadrant_buzz'", :isChecked)
您也可以在 Calabash 中使用 :checked。
isChecked 有效。
irb(main):001:0> query("android.widget.Switch",:isChecked) [ [0] true ]