我试图验证最初禁用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
}
}
]发布于 2017-01-27 15:49:35
当按钮被禁用时,它是物理可见的吗?
# 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使用可见性启发式方法来确定视图是否可见。
乍一看,卡拉巴斯似乎不询问是否启用或禁用了UIControl来确定视图是否可见。
发布于 2017-04-27 15:01:43
我也有同样的问题,但我可以提出一个解决办法:
accessibilityIdentifier,类似于my_super_button_hidden,当它被隐藏时,my_super_button_visible否则all关键字accessibilityIdentifier检查可见性在ruby2.4.0,run_loop 2.3.1上进行检查
https://stackoverflow.com/questions/41884024
复制相似问题