UIAPickerWheel 不工作

发布于 2024-12-04 11:24:26 字数 534 浏览 5 评论 0原文

我一直在努力使用 UIAutomation 中的 UIAPickerWheel 来测试 UIDatePicker。它是一个日期选择器,由月、日和年轮组成。这是我的代码。

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.";

I have been struggling with UIAPickerWheel in UIAutomation to test UIDatePicker. It's a date picker 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.";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

゛清羽墨安 2024-12-11 11:24:26

如果您有特定的轮子,则可以使用 .value() 获取当前值,或 selectValue(str) 来选择新值。这是我用来增加所选日期的片段:

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

在本例中,wheels()[1] 是该月中的某一天(选择器的第二个轮子),这就是我想要增加的值。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文