Javascript 如何在UI自动化iPhone应用程序测试中处理UIPickerView?
在以下UI自动化脚本代码中,我能够从UIPickerView获取值,但无法选择选择器:Javascript 如何在UI自动化iPhone应用程序测试中处理UIPickerView?,javascript,iphone,xcode,cocoa-touch,ios-ui-automation,Javascript,Iphone,Xcode,Cocoa Touch,Ios Ui Automation,在以下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); v
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();
我可能做错了什么?答案在信息242678中
基本上,你必须:
pickerWheel.tapWithOptions({x:hitPointX, y:hitPointY}, {touchCount:1, tapCount:1});
诀窍在于命中点必须位于下一行或上一行。答案在消息242678中
基本上,你必须:
pickerWheel.tapWithOptions({x:hitPointX, y:hitPointY}, {touchCount:1, tapCount:1});
诀窍在于命中点必须位于下一行或上一行。这是pickerWheel自动化的漂亮javascript实现
这是pickerWheel自动化的漂亮javascript实现
您应该使用.selectValue()方法
我发现在某些情况下,selectValue会抛出“在尝试运行脚本时发生异常”。当目标未正确设置时会发生这种情况-记录元素树并检查UAITarget name是否为空(对于模拟器,它应该是“iPhone模拟器”)。请参阅“目标选择”下的“编辑活动目标”,并确保在“选项”下设置了正确的模拟器版本(您已为其编译)。您应该使用.selectValue()方法
我发现在某些情况下,selectValue会抛出“在尝试运行脚本时发生异常”。当目标未正确设置时会发生这种情况-记录元素树并检查UAITarget name是否为空(对于模拟器,它应该是“iPhone模拟器”)。请参阅“目标选择”下的“编辑活动目标”,并确保在“选项”下设置了正确的模拟器版本(您已为其编译)。适用于XUIAutomation(iOS 10+)
用于XUIAutomation(iOS 10+)
app.pickers
.children(matching: .pickerWheel)
.element
.adjust(toPickerWheelValue: "My Value")