sendKeys doesn't work for UIAPickerWheel

Here is my environment: Mavericks OS, Appium 1.3.1, java-client 2.0.0, XCode6.1, iPhone5s, iOS8.1

Here are my codes:
//UIAPickerWheel is a child of the ticketType element.
WebElement picker = ticketType.findElement(By.className(“UIAPickerWheel”));

I am trying to select a value on the UIAPickerWheel but got this error, “debug: Got result from instruments: {“status”:17,“value”:”- selectValue requires a valid value"}". As you see in the log below, Appium was able to find UIAPickerwheel, but when it comes to set the value, it returned an error. I saw an issue was raised but in the older version of Appium, and no-one has submitted an issue for this. Can someone help look into it to determine whether it is an Appium bug?

Currently, my workaround is to use device.swipe() to change the value.

Here is a snippet of my Appium.log.

2014-11-18 22:38:35:509 - info: [debug] Waiting up to 10000ms for condition
2014-11-18 22:38:35:509 - info: [debug] Pushing command to appium work queue: “au.getElementByType(‘UIAPickerWheel’, ‘138’)”
2014-11-18 22:38:35:509 - info: [debug] Sending command to instruments: au.getElementByType(‘UIAPickerWheel’, ‘138’)
2014-11-18 22:38:36:548 - info: [debug] [32m[INST] 2014-11-18 22:38:39 +0000 Debug: Got new command 39 from instruments: au.getElementByType(‘UIAPickerWheel’, ‘138’)[39m
2014-11-18 22:38:36:555 - info: [debug] [32m[INST] 2014-11-18 22:38:39 +0000 Debug: evaluating au.getElementByType(‘UIAPickerWheel’, ‘138’)[39m
2014-11-18 22:38:36:560 - info: [debug] [32m[INST] 2014-11-18 22:38:39 +0000 Debug: evaluation finished[39m
2014-11-18 22:38:36:565 - info: [debug] [32m[INST] 2014-11-18 22:38:39 +0000 Debug: responding with:[39m
2014-11-18 22:38:36:570 - info: [debug] [32m[INST] 2014-11-18 22:38:39 +0000 Debug: Running system command #40: /Applications/ /Applications/ /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“141”}}…[39m
2014-11-18 22:38:36:590 - info: [debug] Socket data received (40 bytes)
2014-11-18 22:38:36:591 - info: [debug] Socket data being routed.
2014-11-18 22:38:36:591 - info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“141”}}
2014-11-18 22:38:36:591 - info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“141”},“sessionId”:“3c7b1d78-05a3-4ebb-b51a-6fbc216e436d”}
2014-11-18 22:38:36:591 - info: [37m<-- POST /wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/element/138/element [39m[32m200[39m[90m 1082.489 ms - 89[39m [90m{“status”:0,“value”:{“ELEMENT”:“141”},“sessionId”:“3c7b1d78-05a3-4ebb-b51a-6fbc216e436d”}[39m
2014-11-18 22:38:36:594 - info: [37m–>[39m [37mPOST[39m [37m/wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/element/141/value[39m [90m{“id”:“141”,“value”:[“1”]}[39m
2014-11-18 22:38:36:595 - info: [debug] Pushing command to appium work queue: “au.getElement(‘141’).setValueByType(‘1’)”
2014-11-18 22:38:36:595 - info: [debug] Sending command to instruments: au.getElement(‘141’).setValueByType(‘1’)
2014-11-18 22:38:37:508 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Debug: Got new command 40 from instruments: au.getElement(‘141’).setValueByType(‘1’)[39m
2014-11-18 22:38:37:514 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Debug: evaluating au.getElement(‘141’).setValueByType(‘1’)[39m
2014-11-18 22:38:37:654 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Debug: - selectValue requires a valid value[39m
2014-11-18 22:38:37:849 - info: [debug] Socket data received (62 bytes)
2014-11-18 22:38:37:850 - info: [debug] Socket data being routed.
2014-11-18 22:38:37:850 - info: [debug] Got result from instruments: {“status”:17,“value”:"- selectValue requires a valid value"}
2014-11-18 22:38:37:850 - info: [debug] Responding to client with error: {“status”:17,“value”:{“message”:“An error occurred while executing user supplied JavaScript.”,“origValue”:"- selectValue requires a valid value"},“sessionId”:“3c7b1d78-05a3-4ebb-b51a-6fbc216e436d”}
2014-11-18 22:38:37:851 - info: [37m<-- POST /wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/element/141/value [39m[31m500[39m[90m 1256.796 ms - 197[39m [90m[39m
2014-11-18 22:38:37:853 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Error: VerboseError: - selectValue requires a valid value[39m
2014-11-18 22:38:37:936 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Error: Error during eval: selectValue@[native code]
eval code
eval@[native code]
global code@file:///Applications/[39m
2014-11-18 22:38:37:947 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Debug: responding with:[39m
2014-11-18 22:38:37:954 - info: [debug] [32m[INST] 2014-11-18 22:38:40 +0000 Debug: Running system command #41: /Applications/ /Applications/ /tmp/instruments_sock 2,{“status”:17,“value”:"- selectValue requires a valid value"}…[39m
2014-11-18 22:38:38:374 - info: [37m–>[39m [37mGET[39m [37m/wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/screenshot[39m [90m{}[39m

@LuongHuynh can you read thru this and make sure you have your iOS8 environment setup correctly?

Hi 0x1mason,
I read it through and pretty sure my environment is setup correctly. My setup is on a physical device rather than on a simulator. I had an xcode build the application directly on the iPhone 5S with IOS8.1. Then on my appium test configuration, I had these:

My test is able to run and everything. It can navigate through the apps, but I got an issue in this case on the sendKeys of the UIAPickerWheel object. Based on my setup above, is there anything else that I am missing? If the setup isn’t good, I would expect my test would fail in the beginning, wouldn’t it? Please let me know. Thanks!

No, there is a specific issue with sendKeys and iOS8. Please read the setup instructions I linked so we can rule that out as the issue.

As I had mentioned above that I already went through the setup instructions. I doubt that I missed anything. However to be safe, can someone test it out to see if it is actually an issue with sendKeys and iOS8, and Appium1.3.1? If it is, have we submitted an issue/bug to the Appium team so they can fix it and hopefully have the fix in the next release? If there was already a submitted issue, please post the number so I can follow. If not, I can submit one if needed.

Looks like someone else reported this issue. You might want to post your trace there, too.

Thank you. My log is similar to the posted log so I only commented that I ran into the same issue.

I also have same issue, any solutions found til now?

try this way with writing two sentence to set value:
element.sendKeys(“Same Value as Above”);

same is worked for me in iOS.

Hey Lakhani,

I tried the way you suggested, but still not working…

so for you case, you tried use sendkeys only not working, and then add setValue() it works? maybe sendKeys only also works for you?

My case is some picker wheels work, some not working

Hi Cris,
Sorry for typo mistakes, you have to write above mentioned sentences in reverse order like first you have to write sendkeys and then setValue.

element.sendKeys(“Same Value as Above”);

here sendKeys sentence will first focus your value in drop down box and setvalue will set the value.

still no luck :frowning:

I have 2 wheel pickers. one for weight number, one for weight unit. (e.g. 123 ft)

when i sendkeys to the unit picker, it scroll successfully.

and it trigger the number picker to automatically scroll to other values

now when i sendkeys + set value to the number picker, it will throw exception (from sendkey call)

I have also observed one this while implementing above at my side, if your screen has multiple UIAPickerWheel in same page. while recapturing screen using appium inspector, index of object get changed like initially if it’s showing UIAPickerWheel[1] and now if just refresh the screen of app and recapture it will show UIAPickerWheel[2]. it is suggested to use some other property like label or name to identify the object. this what i have observed at my end, you might not get same issue.