如何在 UI Automation iPhone 应用程序测试中处理 UIPickerView?
在以下 UI 自动化脚本代码中,我能够从 UIPickerView 获取值,但无法选择选择器:
var picker = window.pickers();
UIALogger.logMessage("picker array count: " + picker.length);
var pickerWheels = picker[0].wheels();
UIALogger.logMessage("picker Wheel count: " + pickerWheels.length);
var pickerWheelsValues =pickerWheels[0].values();
UIALogger.logMessage("picker Values count: " + pickerWheelsValues);
pickerWheels[0].values()[0].tap();
我可能做错了什么?
In the following UI Automation script code, I'm able to get the values from a UIPickerView, but I'm not able to select the picker:
var picker = window.pickers();
UIALogger.logMessage("picker array count: " + picker.length);
var pickerWheels = picker[0].wheels();
UIALogger.logMessage("picker Wheel count: " + pickerWheels.length);
var pickerWheelsValues =pickerWheels[0].values();
UIALogger.logMessage("picker Values count: " + pickerWheelsValues);
pickerWheels[0].values()[0].tap();
What might I be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
答案就在 Apple 开发论坛 消息 242678 中。
上你必须:
本质 hitPoint 必须位于下一行或上一行。
The answer is in the apple dev forums message 242678.
essentially you have to:
The trick is that the hitPoint has to be in the next or previous row.
这是 pickerWheel 自动化的漂亮 javascript 实现
https://devforums.apple.com/message/242678
This is beautiful javascript implementation of pickerWheel automation
https://devforums.apple.com/message/242678
您应该使用 .selectValue() 方法。
我发现在某些情况下 selectValue 会抛出“尝试运行脚本时发生异常”。当目标未正确设置时会发生这种情况 - 记录元素树并检查 UAITarget 名称是否不为空(如果是模拟器,则应为“iPhone Simulator”)。请参阅目标选择下的编辑活动目标,并确保在选项下设置正确的模拟器版本(您已编译)。
You should use .selectValue() method.
I found that in some situations selectValue throws "An exception occurred while trying to run the script." This happens when target is not correctly set- log element tree and check if UAITarget name is not empty (in case of simulator it should be "iPhone Simulator"). See Edit Active Target under target selection and make sure that under Options correct Simulator version (you have compiled for) is set.
适用于 XCUIAutomation(iOS 10+)
For XCUIAutomation (iOS 10+)