Unable to automate UIPickerWheel

I am using appium 1.2.0; Mac OS 10.8.5 and iPhone 5S with iOS 7.1.2.

Now for some reason I am not able to automate UIPickerWheel.

I have tried both means of sendKeys, i.e. sendKeys(“2”) and sendKeys(“2. 2 of 9”) but none of them works.

Here’s the log that I get correspondingly :

info: --> POST /wd/hub/session/6d69d366-845b-4de5-a899-7cc8429bd902/element {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAPicker[1]/UIAPickerWheel[1]"}
debug: Appium request initiated at /wd/hub/session/6d69d366-845b-4de5-a899-7cc8429bd902/element
debug: Request received with params: {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAPicker[1]/UIAPickerWheel[1]"}
debug: Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
debug: Sending command to instruments: au.mainApp().getTreeForXML()
debug: Sending command to instruments: au.mainApp().getTreeForXML()
debug: [INST] 2014-08-31 10:09:52 +0000 Debug: Got new command 24 from instruments: au.mainApp().getTreeForXML()
       
debug: [INST] 2014-08-31 10:09:52 +0000 Debug: evaluating au.mainApp().getTreeForXML()
       
debug: [INST] 2014-08-31 10:09:53 +0000 Debug: evaluation finished
       
debug: [INST] 2014-08-31 10:09:53 +0000 Debug: Result is not protocol compliant, wrapping
       
debug: [INST] 2014-08-31 10:09:53 +0000 Debug: Running system command #25: /usr/local/Cellar/node/0.10.29/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"UIAApplication":{"@":{"name":"xyz","label":"xyz","value":null,"dom":null,"enabled":true,"valid":true,"visible":t...
       
debug: Socket data received (8192 bytes)
debug: Socket data received (6661 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":{"UIAApplication":{"@":{"name":"xyz","label":"xyz","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0","x":0,"y":20,"width":320,"height":548},">":[{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true
debug: Pushing command to appium work queue: "au.getElementByIndexPath('/0/0/28/0')"
debug: Sending command to instruments: au.getElementByIndexPath('/0/0/28/0')
debug: Sending command to instruments: au.getElementByIndexPath('/0/0/28/0')
debug: [INST] 2014-08-31 10:09:54 +0000 Debug: Got new command 25 from instruments: au.getElementByIndexPath('/0/0/28/0')
       
debug: [INST] 2014-08-31 10:09:54 +0000 Debug: evaluating au.getElementByIndexPath('/0/0/28/0')
       
debug: [INST] 2014-08-31 10:09:54 +0000 Debug: evaluation finished
       
debug: [INST] 2014-08-31 10:09:54 +0000 Debug: Running system command #26: /usr/local/Cellar/node/0.10.29/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"6"}}...
       
debug: Socket data received (38 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":{"ELEMENT":"6"}}
debug: Responding to client with success: {"status":0,"value":{"ELEMENT":"6"},"sessionId":"6d69d366-845b-4de5-a899-7cc8429bd902"}
info: <-- POST /wd/hub/session/6d69d366-845b-4de5-a899-7cc8429bd902/element 200 2717.696 ms - 87 {"status":0,"value":{"ELEMENT":"6"},"sessionId":"6d69d366-845b-4de5-a899-7cc8429bd902"}
info: --> POST /wd/hub/session/6d69d366-845b-4de5-a899-7cc8429bd902/element/6/value {"id":"6","value":["2. 2 of 9"]}
debug: Appium request initiated at /wd/hub/session/6d69d366-845b-4de5-a899-7cc8429bd902/element/6/value
debug: Request received with params: {"id":"6","value":["2. 2 of 9"]}
debug: Pushing command to appium work queue: "au.getElement('6').setValueByType('2. 2 of 9')"
debug: Sending command to instruments: au.getElement('6').setValueByType('2. 2 of 9')
debug: Sending command to instruments: au.getElement('6').setValueByType('2. 2 of 9')
debug: [INST] 2014-08-31 10:09:55 +0000 Debug: Got new command 26 from instruments: au.getElement('6').setValueByType('2. 2 of 9')
       
debug: [INST] 2014-08-31 10:09:55 +0000 Debug: evaluating au.getElement('6').setValueByType('2. 2 of 9')
       
debug: [INST] 2014-08-31 10:09:55 +0000 Debug: - selectValue requires a valid value

debug: Socket data received (62 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":17,"value":"- selectValue requires a valid value"}
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":"6d69d366-845b-4de5-a899-7cc8429bd902"}
info: <-- POST /wd/hub/session/6d69d366-845b-4de5-a899-7cc8429bd902/element/6/value 500 1126.228 ms - 197

I get the same error when trying with sendKeys(“2”).

Any help? Stuck on this problem for past 48 hours!

I use from 1.2.1 to 1.2.2. No luck on get “values” from pickerwheel.
when execute “au.getElement(2).value()”, I get the correct value of the picker wheel, but not for “au.getElement(2).values()”.

Exactly. Even I updated to appium 1.2.2. However, I am getting the same error on doing a sendKeys() to automate the UIPickerWheel.

Did you try selectValue?
My problem here is:
1.2.1/1.2.2: Cannot get value and values from pickerwheel.
1.2.0: Cannot selectValue/sendKeys text values(like month of a date picker). but numbers are OK like day and year.

This might sound a bit naive, but how do you do a ‘selectValue’? I don’t think it’s a native AppiumDriver function.

Regarding your problem, I am able to get value for pickerwheel for 1.2.1 and 1.2.2 as well.

SendKeys will run selectValue according to Jonathon from a thread. (sorry I don;t remember the link) So I try to execute selectValue using Inspector->Text->Execute Script. like: au.getElement(2).selectValue(‘1234’). You can get the element ID by tap it and read from log. Because I didn’t try a lot of versions, I think it worth a try to see if it is new version appium issue. In my case, 1.2.0, selectValue(‘2008’) and SendKeys(“2008”) both works (only for number values).

About get values: GetAttribute of C# lib returns string, that’s the problem. If any of appium person see my comment, I hope they can push selenium WebDriver to have a way to fix this. I temporary add another function GetAttributeRaw to return object type for getting values in 1.2.0. I haven’t got time to look at newer version and why appium failed to get values yet.

Thank you @Alex_Chen. I will give it a try and let you know the result.

I’m facing the same issue. I have an picker wheel which contains the list of countries. Tried both sendKeys() and setValue() but its not working. All the threads i followed indicates that it might be broken so i tried with all the Appium versions till 1.0.0 but no luck so far.

Did you guys find any Solution. I’m also facing the same issue. Any Help much appreciated.

Not yet. I tried SendKeys as well as SelectValue through script executor and yet no success. Right now, I am doing a precise tap on the wheel and scrolling over one element at a time. I will try few more things and let you guys know if anything worked.

Do send_keys on the uiapickerwheel you’re interested in setting. Related question

@JessicaSachs I already tried sendKeys() (I am using Java). It did not work. That’s why the post. :expressionless:

1 Like

Ok so I came across a new situation today.

If the values are integers, like dates (1,2,3 …), then doing a sendKeys doesn’t work but when I did the same thing for a String, like Month (Jan, Feb, Mar … ), it worked. Any thoughts as to why it’s working this way?

Can you give me the snippet for that. I have countries in my picker wheel and your method should work for me.which version of java client you are using?

I do a normal sendKeys() for that.

driver.findElementByAccessibilityId("month").sendKeys("November")

But when I do the same for date, it does not work :

 driver.findElementByAccessibilityId("date").sendKeys("1")

Is it because of int/String issue? As in the numbers in the application is an integer and I am trying to send a String? Any thoughts @jonahss

Are you sure those ID’s are pointing to the right element in the pickerWheel?

I prefer to use the xpath than IDs or names, just to make sure I’m on the right element.

Could you try this>
(x and y will be the number of the element on the path to the specific wheel you want to set the value on)

WebElement _pwDate = driver.findElement(By.xpath(“yourpath/UIAPicker[x]/UIAPickerWheel[y]”));
_pwDate.sendKeys(“1”);

I am also facing the same problem… if u find the solution then post it here

sendKeys is working fine for me.

Neto18, which version of Appium are you using? I currently use Appium 1.3.1, and I also 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. Does anyone have a solution to this or has a bug/issue been submitted?

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] e[32m[INST] 2014-11-18 22:38:39 +0000 Debug: Got new command 39 from instruments: au.getElementByType(‘UIAPickerWheel’, ‘138’)e[39m
2014-11-18 22:38:36:555 - info: [debug] e[32m[INST] 2014-11-18 22:38:39 +0000 Debug: evaluating au.getElementByType(‘UIAPickerWheel’, ‘138’)e[39m
2014-11-18 22:38:36:560 - info: [debug] e[32m[INST] 2014-11-18 22:38:39 +0000 Debug: evaluation finishede[39m
2014-11-18 22:38:36:565 - info: [debug] e[32m[INST] 2014-11-18 22:38:39 +0000 Debug: responding with:e[39m
2014-11-18 22:38:36:570 - info: [debug] e[32m[INST] 2014-11-18 22:38:39 +0000 Debug: Running system command #40: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“141”}}…e[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: e[37m<-- POST /wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/element/138/element e[39me[32m200e[39me[90m 1082.489 ms - 89e[39m e[90m{“status”:0,“value”:{“ELEMENT”:“141”},“sessionId”:“3c7b1d78-05a3-4ebb-b51a-6fbc216e436d”}e[39m
2014-11-18 22:38:36:594 - info: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/element/141/valuee[39m e[90m{“id”:“141”,“value”:[“1”]}e[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] e[32m[INST] 2014-11-18 22:38:40 +0000 Debug: Got new command 40 from instruments: au.getElement(‘141’).setValueByType(‘1’)e[39m
2014-11-18 22:38:37:514 - info: [debug] e[32m[INST] 2014-11-18 22:38:40 +0000 Debug: evaluating au.getElement(‘141’).setValueByType(‘1’)e[39m
2014-11-18 22:38:37:654 - info: [debug] e[32m[INST] 2014-11-18 22:38:40 +0000 Debug: - selectValue requires a valid valuee[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: e[37m<-- POST /wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/element/141/value e[39me[31m500e[39me[90m 1256.796 ms - 197e[39m e[90me[39m
2014-11-18 22:38:37:853 - info: [debug] e[32m[INST] 2014-11-18 22:38:40 +0000 Error: VerboseError: - selectValue requires a valid valuee[39m
2014-11-18 22:38:37:936 - info: [debug] e[32m[INST] 2014-11-18 22:38:40 +0000 Error: Error during eval: selectValue@[native code]
setValueByType@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/7A18F277-8B60-4F9F-9035-0E5DEF054B28/bootstrap-60f23230385b0cfa.js:1969:23
eval code
eval@[native code]
startProcessing@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/7A18F277-8B60-4F9F-9035-0E5DEF054B28/bootstrap-60f23230385b0cfa.js:2660:30
bootstrap@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/7A18F277-8B60-4F9F-9035-0E5DEF054B28/bootstrap-60f23230385b0cfa.js:2726:31
global code@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/7A18F277-8B60-4F9F-9035-0E5DEF054B28/bootstrap-60f23230385b0cfa.js:2735:10e[39m
2014-11-18 22:38:37:947 - info: [debug] e[32m[INST] 2014-11-18 22:38:40 +0000 Debug: responding with:e[39m
2014-11-18 22:38:37:954 - info: [debug] e[32m[INST] 2014-11-18 22:38:40 +0000 Debug: Running system command #41: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:17,“value”:"- selectValue requires a valid value"}…e[39m
2014-11-18 22:38:38:374 - info: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/session/3c7b1d78-05a3-4ebb-b51a-6fbc216e436d/screenshote[39m e[90m{}e[39m

Identify elements using the findElementsbyclassname of UIAPickerwheel and then use sendkeys for your particular element lets say for year, month and date individually. i am doing this and its working for me.

1 Like