Unable to automate UIPickerWheel

@jonahss : doesn’t setValue function implementation supports pickerwheel object ? i tried and failed so still using sendkeys which is quiet slow and flakey in ios.

@bootstraponline knows much more about the current state of sendkeys than I do.
I know that this is an area of appium we really want to improve.

ok, I get it @jonahss, thanks for replying. However this question is little off the track but important to know, what is the alternative to identify the desired pickerwheel in shown image ? [There are 2 pickers, I guess one is coming from other screens which ain’t visible @ the moment, and so xpath keeps changing somtime in ‘window[1]’ and sometimes in window [2] ],
I tried with by className=UIAPickerWheel and tagName=UIAPickerWheel but both doesn’t work.
(my idea was to take in list and checking for visibility and performing action )
I also see, ios uiautomation strategy but couldn’t find any exact example in java to try it, is it more like passing javascript to instruments !! , will that work for pickewheel objects?

Hi,

I too have been wrestling with this for a while, but i got it working tonight.

One of my picker wheels displays a min value for a search. On a device the wheel displays currency, like $20,000… but in the object inspector, the value is showing as “$20,000 2. of 45”

The code below has worked for me.

driver.findElements(By.className(“UIAPickerWheel”)).get(0).sendKeys("$20,000");

I also do this in python:

621     def select_picker_wheel_by_name(self, label, name):                         
622         """                                                                     
623         Helper function: Make selection on a picker wheel                       
624                                                                                 
625         Arguments:                                                              
626             label -- which picker wheel to select from                          
627             name -- picker wheel selection we want                              
628         """                                                                     
629         picker_wheel = self.driver.find_element_by_class_name(                  
630             "UIAPickerWheel")                                                   
631         try:                                                                    
632             # TODO: name vs. value attrib issue?                                
633             picker_wheel.send_keys(name)                                        
634         except WebDriverException as e:                                         
635             self.log.error(                                                     
636                 "Cannot select {0} from the picker wheel: {1}".format(          
637                     name, e)) 

and it works great as long as the string you’re selecting is a “name” attribute, but I get a WebDriverException if the selection is also populated as a “value” attribute. Hrm.

Hey,

I tried to select a random month with year, I m unable to select it as scroll/swipe is not working.

PS: It always try to select a current value only as I understand UIAPickerWheel isn’t having list of values, so I try to scroll it, but could luck, any valuable suggestion will be appreciated.

Below is my code snippet with image:

//Click on select from year dropdown driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[7]")).click();

//Get number of UIAPickerWheel’s
List DatePicker = driver.findElements(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAPicker[1]/UIAPickerWheel"));
for (int i = 1; i <=DatePicker.size(); i++) {
IOSElement we = (IOSElement) driver.findElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIAPicker[1]/UIAPickerWheel["+(i)+"]");
driver.scrollTo(“June”);
we.sendKeys(“June”);
}

Any input will be appreciated…

Maybe wrong use of scroll/swipe here. U can try “send_keys”.

Sendkey throws error, Still I m working on it for getting the proper solution.

I have the same problem with appium 1.5.3
sendKeys() works perfect for strings, but now I am facing a pickerwheel with integers as values and always get the error message: “selectValue requires a valid value”

And I am pretty sure I am addressing the right element. Any hints for me?

Debug: Got new command 38 from instruments: au.getElement('28').setValueByType('1')
Debug: evaluating au.getElement('28').setValueByType('1')
Debug: - selectValue requires a valid value
[HTTP] <-- POST /wd/hub/session/47060285-5eb6-489b-8f54-d8f8b629cca6/element/28/value 500 2150 ms - 123 
[HTTP] --> GET /wd/hub/session/47060285-5eb6-489b-8f54-d8f8b629cca6/screenshot {}
[MJSONWP] Calling AppiumDriver.getScreenshot() with args: ["47060285-5eb6-489b-8f54-d...
[debug] [iOS] Executing iOS command 'getScreenshot'
[debug] [UIAuto] Sending command to instruments: au.capture('screenshot462a743b-ddbd-4088-ad46-91c48aaec28d')
[debug] [Instruments] [INST] 2016-11-23 12:50:07 +0000 Error: VerboseError: - selectValue requires a valid value
[debug] [Instruments] [INST] 2016-11-23 12:50:07 +0000 Error: Error during eval: selectValue@[native code]  setValueByType@file:///Applications/Appium.app/Contents/Resources/node_modules/5AEF3E4D-50C3-41DF-BE1B-2E047AB690A8/bootstrap-6e6eb39e54069ac8.js:2084:23
eval code
eval@[native code]
startProcessing@file:///Applications/Appium.app/Contents/Resources/node_modules/5AEF3E4D-50C3-41DF-BE1B-2E047AB690A8/bootstrap-6e6eb39e54069ac8.js:2793:30
bootstrap@file:///Applications/Appium.app/Contents/Resources/node_modules/5AEF3E4D-50C3-41DF-BE1B-2E047AB690A8/bootstrap-6e6eb39e54069ac8.js:2861:31
global code@file:///Applications/Appium.app/Contents/Resources/node_modules/5AEF3E4D-50C3-41DF-BE1B-2E047AB690A8/bootstrap-6e6eb39e54069ac8.js:2870:10

[debug] [Instruments] [INST] 2016-11-23 12:50:07 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-11-23 12:50:07 +0000 Debug: Running system command #39: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/9_/96z7l14n37sfbwdvbm9n95wh0000gr/T/instruments_sock 2,{"status":17,"...

i think this is not in java