Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIAPickerWheel.selectValue()不适用于UIDatePicker中的文本值_Ios_Ios Ui Automation - Fatal编程技术网

Ios UIAPickerWheel.selectValue()不适用于UIDatePicker中的文本值

Ios UIAPickerWheel.selectValue()不适用于UIDatePicker中的文本值,ios,ios-ui-automation,Ios,Ios Ui Automation,我已经创建了一个简单的项目,它使用的故事板只包含一个mode=Date的UIDatePicker(因此日期看起来像“2011年11月28日”) 在Instruments UI Automation中,我试图设置各个日期选择器控制盘的值 我可以成功地使用selectValue()方法设置包含数值的控制盘,但无法设置月份的文本值,例如“十一月” 这很有效 target.frontMostApp().mainWindow().pickers()[0].wheels()[1].selectValue(1

我已经创建了一个简单的项目,它使用的故事板只包含一个mode=Date的UIDatePicker(因此日期看起来像“2011年11月28日”)

在Instruments UI Automation中,我试图设置各个日期选择器控制盘的值

我可以成功地使用selectValue()方法设置包含数值的控制盘,但无法设置月份的文本值,例如“十一月”

这很有效

target.frontMostApp().mainWindow().pickers()[0].wheels()[1].selectValue(12);
但这不是

target.frontMostApp().mainWindow().pickers()[0].wheels()[0].selectValue("November");
我得到错误:
脚本抛出了一个未捕获的JavaScript错误:-selectValue在具有未定义值的选择器上不受支持

我已经完成了一个
UIATarget.localTarget().frontMostApp().logElementTree()
并且可以看到值是正确的:

UIAPickerWheel:value:11ven rect:{{1142},{146216}


请任何人告诉我可能做错了什么,非常感谢。

我会点击,直到我的价值达到我想要的。由于设置的值为12个月,因此它将滚动

while(target.frontMostApp().mainWindow().pickers()[0].wheels()[0].value != "November"){
  target.frontMostApp().mainWindow().pickers()[0].wheels()[0].tap();
}
value不是变量,它是一个函数,所以您应该像我使用的那样在month wheel上调用
value()

tapWithOptions()
将带您进入控制盘的下一行。

最新版本的xcode(4.5.2)对此进行了修正


它现在可以工作了。

只需使用

var pickerWheel1Values  = picker.wheels()[1]. values();
如果你想设定十一月,就这么做吧

picker.wheels()[index]. selectValue (pickerWheel1Values[10]);

对于使用Appium的任何人,请参见讨论板上的此页:

流程如下所示:

  • 获取选择器元素(标记名:picker)
  • 获取该选择器的所有轮子(标记名:pickerwheel)
  • 您可以通过执行element.getAttribute(“值”)来列出该控制盘的值
  • 您可以通过执行element.setValue(myNewValue)来设置值
最后一步是错误的,您需要使用sendKeys()而不是setValue()

对于一个真实的例子,比如我如何使用它,应该是这样的

String pickerWheelLocation = "UIATarget.localTarget().frontMostApp().windows()[3].pickers()[0].elements()[0]"
By pickerWheelBy = MobileBy.IosUIAutomation(pickerWheelLocation)
IOSElement pickerWheel = WebDriverHelper.getDriver().findElement(pickerWheelBy);
pickerWheel.sendKeys("New Value");

IOSElement doneButton = WebDriverHelper.getDriver().findElement(MobileBy.IosUIAutomation("UIATarget.localTarget().frontMostApp().windows()[2].toolbars()[0].buttons()["Done"]"));
    doneButton.click();

你好,好主意,但这不起作用-当我尝试这个方法时,我只是陷入了一个无限循环,车轮没有滚动:-(while(monthWheel.value!=“June”){monthWheel.tapWithOptions({tapOffset:{x:0.5,y:0.33});monthWheel.logElementTree();target.delay(0.5);}虽然monthWheel.value仍然没有返回有效的结果,但您在这里是否取得了任何进展?
picker.wheels()[index]. selectValue (pickerWheel1Values[10]);
String pickerWheelLocation = "UIATarget.localTarget().frontMostApp().windows()[3].pickers()[0].elements()[0]"
By pickerWheelBy = MobileBy.IosUIAutomation(pickerWheelLocation)
IOSElement pickerWheel = WebDriverHelper.getDriver().findElement(pickerWheelBy);
pickerWheel.sendKeys("New Value");

IOSElement doneButton = WebDriverHelper.getDriver().findElement(MobileBy.IosUIAutomation("UIATarget.localTarget().frontMostApp().windows()[2].toolbars()[0].buttons()["Done"]"));
    doneButton.click();