葫芦iOS:查询未列出禁用按钮

葫芦iOS:查询未列出禁用按钮,ios,automation,calabash,calabash-ios,Ios,Automation,Calabash,Calabash Ios,我正在尝试验证初始禁用的UIButton是否存在continueButton.isEnabled=false 当我在葫芦ios控制台中检查树时,我得到以下结果 [UIWindow] [UIView] [UIView] [MyProject.GradientView] [UIImageView] [id:logo-1] [label:Logo 1] [UIImageView] [id:logo-2] [l

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

当我在
葫芦ios控制台中检查树时,我得到以下结果

[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
然而,当我尝试使用
查询(“按钮”)
时,我得到一个空数组。如果启用该按钮并再次使用查询,则结果为:

[
    [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
        }
    }
]

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

  # 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")
为什么在使用查询时未列出禁用的按钮

葫芦使用可见性启发式来确定视图是否可见


乍一看,葫芦并没有询问任何关于是否启用或禁用UIControl以确定视图是否可见的问题。

我也有同样的问题,但我可以建议解决方法:

  • 当按钮隐藏或可见时,为按钮指定不同的
    可访问性标识
    ,例如当按钮隐藏时为
    我的超级按钮
    ,否则为
    我的超级按钮
  • 在按钮查询中始终使用
    all
    关键字
  • 通过检查可访问性标识来检查可见性
  • 像以前一样检查启用状态

  • 检查ruby 2.4.0,运行\u loop 2.3.1

    谢谢您的回复。我用
    查询(“所有按钮”)
    的结果更新问题。如您所见,按钮位于屏幕边界内,其alpha值为1。我不明白为什么
    visible
    更改为'0`@jmoody,+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")