iOS Instruments - UIADatePicker错误 - 元素不可见

时间:2013-12-04 20:14:29

标签: ios ipad xcode5 ios-ui-automation xcode-instruments

我正在尝试从我的应用上的UIPickerWheel中选择一个值。点击日期字段时弹出选择器轮,值为月(1月,2月,...),日期(1,2,...)和年(2013年,2012 ...)

当我执行以下操作时,我得到了正确的值

**

selectedvalue = target.frontMostApp().mainWindow().pickers()[0].wheels()[0].value();
UIALogger.logDebug(selectedValue)

**

但是,当我尝试使用以下代码点击方向盘时:

target.frontMostApp().mainWindow().pickers()[0].wheels()[0].tap();

我收到一条错误,指出 - target.frontMostApp()。mainWindow()。pickers()[0] .wheels()[0] 无法点击,因为该元素不可见在yyyyscript的xxx线上

我检查了UIAPickerWheel上的其他线程,这个特定的步骤似乎很简单。然而,我感到困惑的是,从车轮上取回了值,但没有完成攻击

非常感谢任何帮助!

谢谢和问候, 维奈

1 个答案:

答案 0 :(得分:0)

我有完全相同的问题,日期选择器不在树中

 UIAWindow "(null)" {{0, 0}, {320, 568}}
elements: {
    UIANavigationBar "Step 1: My Details" {{0, 20}, {320, 44}}
    elements: {
        UIAImage "(null)" {{0, 0}, {320, 64}}
        elements: {
            UIAImage "(null)" {{0, 64}, {320, 0.5}}
        }
        UIAButton "UINavigationBarBackIndicatorDefault.png" {{8, 32}, {12.5, 20.5}}
        UIAStaticText "Step 1: My Details" {{88.5, 28}, {143, 27}}
    }
    UIAScrollView "(null)" {{0, 64}, {320, 310}}
    elements: {
        UIATextField "Ird" {{0, -4}, {320, 50}}
        UIAImage "(null)" {{316.5, -4}, {3.5, 310}}
        UIATextField "FirstName" {{0, 46}, {320, 50}}
        UIATextField "MiddleName" {{0, 96}, {320, 50}}
        UIATextField "LastName" {{0, 146}, {320, 50}}
        UIATextField "DOB" {{0, 196}, {320, 50}}
        UIAButton "Next" {{10, 256}, {300, 50}}
        UIAImage "(null)" {{0, 302.5}, {320, 3.5}}
    }
    }

DOB文本字段的inputView设置为datepick

通过使用Reveal,我可以看到日期选择器现在位于uitexteffectsview

要基本上回答我自己的问题和你的机制。你可以用这个选择所有的uipickers

$('window > picker')[0]

我设法通过运行此

获取完整日志
UIALogger.logDebug("Pickers " + UIATarget.localTarget().logElementTree())

这是完整的日志

    elements: {
    UIAApplication "MyApp" {{0, 20}, {320, 548}}
    elements: {
        UIAWindow "(null)" {{0, 0}, {320, 568}}
        elements: {
            UIANavigationBar "Step 1: My Details" {{0, 20}, {320, 44}}
            elements: {
                UIAImage "(null)" {{0, 0}, {320, 64}}
                elements: {
                    UIAImage "(null)" {{0, 64}, {320, 0.5}}
                }
                UIAButton "UINavigationBarBackIndicatorDefault.png" {{8, 32}, {12.5, 20.5}}
                UIAStaticText "Step 1: My Details" {{88.5, 28}, {143, 27}}
            }
            UIAScrollView "(null)" {{0, 64}, {320, 310}}
            elements: {
                UIATextField "Ird" {{0, -4}, {320, 50}}
                UIAImage "(null)" {{316.5, -4}, {3.5, 310}}
                UIATextField "FirstName" {{0, 46}, {320, 50}}
                UIATextField "MiddleName" {{0, 96}, {320, 50}}
                UIATextField "LastName" {{0, 146}, {320, 50}}
                UIATextField "DOB" {{0, 196}, {320, 50}}
                UIAButton "Next" {{10, 256}, {300, 50}}
                UIAImage "(null)" {{0, 302.5}, {320, 3.5}}
            }
        }
        UIAWindow "(null)" {{0, 0}, {320, 568}}
        elements: {
            UIAPicker "(null)" {{0, 352}, {320, 216}}
            elements: {
                UIAPickerWheel "(null)" {{29, 314.5}, {135, 291}}
                UIAPickerWheel "(null)" {{169, 314.5}, {46, 291}}
                UIAPickerWheel "(null)" {{220, 314.5}, {72, 291}}
            }
        }
        UIAWindow "(null)" {{0, 0}, {320, 568}}
        elements: {
            UIAStatusBar "(null)" {{0, 0}, {320, 20}}
            elements: {
                UIAElement "Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top" {{6, 0}, {38, 20}}
                UIAElement "3 of 3 Wi-Fi bars" {{49, 0}, {13, 20}}
                UIAElement "9:49 AM" {{137, 0}, {47, 20}}
                UIAElement "100% battery power" {{290, 0}, {25, 20}}
            }
        }
    }
}