我正在尝试验证最初被禁用的UIButton continueButton.isEnabled = false
的存在。
当我在calabash-ios console
中检查树时,我得到以下结果
[UIWindow]
[UIView]
[UIView]
[MyProject.GradientView]
[UIImageView] [id:logo-1] [label:Logo 1]
[UIImageView] [id:logo-2] [label:Logo 2]
[MyProject.UnderlinedTextField] [label:Email] [text:]
[UITextFieldLabel] [label:EMAIL] [text:EMAIL]
[UIAccessibilityTextFieldElement] [label:Email] [text:EMAIL]
[UIButton] [label:Let's go]
[UIButtonLabel] [label:LET'S GO] [text:LET'S GO]
true
然而,当我尝试使用query("button")
时,我得到一个空数组。如果该按钮已启用并再次使用查询,则结果为:
[
[0] {
"id" => nil,
"description" => "<UIButton: 0x7fcdc8f1b6b0; frame = (23 571; 329 63); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x608000228b20>>",
"label" => "Let's go",
"frame" => {
"y" => 571,
"x" => 23,
"width" => 329,
"height" => 63
},
"accessibilityElement" => true,
"value" => nil,
"alpha" => 1,
"enabled" => true,
"visible" => 1,
"selected" => false,
"class" => "UIButton",
"rect" => {
"y" => 571,
"center_x" => 187.5,
"center_y" => 602.5,
"x" => 23,
"width" => 329,
"height" => 63
}
}
]
为什么使用查询时未列出禁用按钮?有没有办法验证按钮是否存在而不管其启用状态如何?
更新
按照jmoody的建议使用query ("all button")
时,我可以按下按钮。
[
[0] {
"id" => nil,
"description" => "<UIButton: 0x7fe05ad18000; frame = (23 571; 329 63); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x60000022d940>>",
"label" => "Lets go",
"frame" => {
"y" => 571,
"x" => 23,
"width" => 329,
"height" => 63
},
"accessibilityElement" => true,
"value" => nil,
"alpha" => 1,
"enabled" => false,
"visible" => 0,
"selected" => false,
"class" => "UIButton",
"rect" => {
"y" => 571,
"center_x" => 187.5,
"center_y" => 602.5,
"x" => 23,
"width" => 329,
"height" => 63
}
}
]
答案 0 :(得分:1)
当按钮被禁用时,它是否在物理上可见?
# All buttons regardless of visibility.
query("all button")
# Ask every button if is enabled.
query("all button", :isEnabled)
# Filter buttons by disabled
query("all button isEnabled:0")
为什么使用查询时未列出禁用按钮?
Calabash使用可见性启发式来确定视图是否可见。
乍一看,看起来Calabash不会询问是否启用了UIControl以确定视图是否可见。
答案 1 :(得分:0)
我有同样的问题,但我可以建议一个解决方法:
accessibilityIdentifier
,类似my_super_button_hidden
,隐藏时为my_super_button_visible
all
关键字accessibilityIdentifier
检查ruby 2.4.0,run_loop 2.3.1