gpt4 book ai didi

ios - 葫芦 iOS : query not listing disabled button

转载 作者:行者123 更新时间:2023-11-29 11:49:22 26 4
gpt4 key购买 nike

我正在尝试验证最初禁用 continueButton.isEnabled = false 的 UIButton 是否存在。

当我在 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
}
}
]

最佳答案

当按钮被禁用时,它在物理上是否可见?

  # 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")

Why a disabled button is not listed when using query?

Calabash 使用可见性启发法来确定 View 是否可见。

乍一看,Calabash 似乎不会询问有关 UIControl 是启用还是禁用的任何信息来确定 View 是否可见。

关于ios - 葫芦 iOS : query not listing disabled button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41884024/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com