Search code examples
iphoneios-ui-automationuipicker

Handle picker in UIAutomation


I have picker view with only one component, and 5 values in the component.

I could get the number of wheels , and values in the component, as below

var picker = window.pickers(); 

UIALogger.logMessage("picker array count: " + picker.length);

var pickerWheels = picker[0].wheels();
var pickerWheelsValues =pickerWheels[0].values();

When i log the statement, like "pickerWheels[0].values()[1]", It does displays the first item.

The issue is, how to tap on it ?

pickerWheels[0].values()[1].tap(); // DOESN'T WORK

Can some one provide some input, how to tap on the picker wheel elements ?

I have tried also implementing the UIPickerViewAccessibilityDelegate and overridden //Set the accessiblity for each component.

- (NSString *)pickerView:(UIPickerView *)thePickerView accessibilityLabelForComponent:(NSInteger)component{
    thePickerView.isAccessibleElement = YES;
    thePickerView.accessibilityLabel= @"label";
    return @"label";
}

Solution

  • There is a post on O'Reilly that shows one way to interact with pickers (scroll down to the reply posted by 'zpthacker').

    Basically it involves calculation of where to tap on the picker to have it go back or forth.

    The sample needs to be tweaked a bit in order to work regarding creation of a Point, for instance to the following

    var tapLoc = new Object();
    tapLoc.x = origin.x+tapWidth;
    tapLoc.y = tapHeight+origin.y;
    target.tap(tapLoc);