开发者

UIAPickerWheel not working

I have been struggling with UIAPickerWheel in UIAutomation to test UIDatePicker. It's a date picker开发者_JS百科 consisting of Month, Day and Year wheels. Here is my code.

var monthWheel = w.pickers()[0].wheels()[0];
UIALogger.logMessage(monthWheel.logElementTree()); // This line output seems right 
// 5) UIAPickerWheel [name:(null) value:September rect:{{x:21, y:265}, {width:147, height:216}}]

UIALogger.logMessage(monthWheel.isValid());  // This line output 1
var length = monthWheel.values().length;  // error: "Result of expression 'monthWheel.values()' [null] is not an object.";


If you have a particular wheel, you can use .value() to get the current value, or selectValue(str) to select a new value. Here's a snippet I use to increment the date selected:

currentDay = datePicker.wheels()[1].value();
//UIALogger.logDebug("current day " + currentDay);
currentDay = parseInt(currentDay) + 1;
datePicker.wheels()[1].selectValue(currentDay);

In this case wheels()[1] is the day of the month (the second wheel of the picker), which is what i wanted to increment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜