iOS Instruments - UIADatePicker Error - Element is not visible

331 views Asked by At

I'm trying to select a value from a UIPickerWheel on my app. The picker wheel pops up when I click on a date field and the values are Month (January, February,...), Date (1,2,...) and Year (2013, 2012...)

I get the correct value when I do the following

**

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

**

However, when I try to tap on the wheel by using the following code:

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

I get an error that states - target.frontMostApp().mainWindow().pickers()[0].wheels()[0] could not be tapped because the element is not visible on line xxx of yyyyscript

I checked other threads on UIAPickerWheel and this particular step seems simple enough. However, I'm baffled as the value is being retrieved from the wheel but tapping is not being done

Any help would be greatly appreciated!

Thanks and regards, Vinay

1

There are 1 answers

0
michael.boost On

I have this exact same issue, the datepicker is not in the tree

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

The DOB textfield has the inputView set to datepick

By using Reveal I can see the datepicker is now under uitexteffectsview

To basically answer my own issue and yours with mechanic.js you can select all uipickers with this

$('window > picker')[0]

I managed to get a full log by running this

UIALogger.logDebug("Pickers " + UIATarget.localTarget().logElementTree())

Here is the full log

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