Problems to swipe and set values on pickerWheel with Java

I’m using Java for automation with Appium (io.appium.java_client.AppiumDriver) and I can’t find a way to swipe or set values on a pickerWheel.

I have found info on blogs, but is not working fine. Isn’t a offical way to do that?

It will be nice having options like:
dragInsideWithOptions({startOffset:{x:0.0, y:0.0}, endOffset:{x:0.0, y:0.0}, duration:1.0}); for swipe and
pickers()[0].wheels()[0].selectValue(“value”); for the pickerWheel

The code given by Appium Inspector isn’t working either.

@jlipps any ideas/workarounds about this?

I need to swipe over a slider, so using the scroll won’t work for me.

Also about the pickerWheel, is there a way to set values on those?


1 Like

use sendKeys to set values on pickerwheels

1 Like

thanks! pickerWheel issue solved.
I was using sendKeys, but it wasn’t working fine (not sure why)

I’ll post a couple of lines here, that may help some other people.

// define a webelement with the pickerWheel you want to set the values on, here I’m using xpath
// then use sendKeys() to set the value

WebElement _pickerWheel = driver.findElement(By.xpath(“yourpath/UIAPicker[1]/UIAPickerWheel[1]”));

Hi Neto,

The code is working for iOS but it is not working for Android. Is there any solution for Android to select date from DatePicker.

Hi @jlipps

Hi Team,

Testing an iOS app with 6.1, 7.1 on the real device,It’s working fine with 6.1, but when i am trying to perform sendskey action on 7.0, 7.1 UIPicker Instruments died.
I had tried with below configuration but did’t got success

MAC 10.10, MAC 10.8
Appium 1.3.3 to 1.3.7
Xcode 5.1,6.2

Find Appium logs

info: --> POST /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/element {“using”:“name”,“value”:“Add % Item Tax Override. 1 of 12”}

warn: [DEPRECATED] The name locator strategy has been deprecated and will be removed. Please use the accessibility id locator strategy instead.
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: “au.getElementByName(‘Add % Item Tax Override. 1 of 12’)”
info: [debug] Sending command to instruments: au.getElementByName(‘Add % Item Tax Override. 1 of 12’)
info: [debug] [INST] 2015-05-22 11:39:42 +0000 Debug: Got new command 26 from instruments: au.getElementByName(‘Add % Item Tax Override. 1 of 12’)
info: [debug] [INST] 2015-05-22 11:39:42 +0000 Debug: evaluating au.getElementByName(‘Add % Item Tax Override. 1 of 12’)
info: [debug] [INST] 2015-05-22 11:39:42 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-05-22 11:39:42 +0000 Debug: Lookup returned [object UIAPickerWheel] with the name “Add % Item Tax Override. 1 of 12” (id: 0).
info: [debug] [INST] 2015-05-22 11:39:42 +0000 Debug: responding with:
info: [debug] [INST] 2015-05-22 11:39:42 +0000 Debug: Running system command #27: /Applications/ /Applications/ /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“0”}}…
info: [debug] Socket data received (38 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“0”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“0”},“sessionId”:“35913ec2-af44-453b-a37d-fe988f104193”}
info: <-- POST /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/element 200 870.085 ms - 87 {“status”:0,“value”:{“ELEMENT”:“0”},“sessionId”:“35913ec2-af44-453b-a37d-fe988f104193”}
info: --> POST /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/element/0/value {“value”:[“I”,“t”,“e”,“m”," “,“A”,“s”,“s”,“o”,“c”,“i”,“a”,“t”,“e”,”."," “,“3”,” “,“o”,“f”,” ",“1”,“2”]}
info: [debug] Pushing command to appium work queue: “au.getElement(‘0’).setValueByType(‘Item Associate. 3 of 12’)”
info: [debug] Sending command to instruments: au.getElement(‘0’).setValueByType(‘Item Associate. 3 of 12’)
info: [debug] [INST] 2015-05-22 11:39:43 +0000 Debug: Got new command 27 from instruments: au.getElement(‘0’).setValueByType(‘Item Associate. 3 of 12’)
info: [debug] [INST] 2015-05-22 11:39:43 +0000 Debug: evaluating au.getElement(‘0’).setValueByType(‘Item Associate. 3 of 12’)
info: [debug] [INST] 2015-05-22 11:39:44 +0000 Fail: The target application appears to have died
info: [debug] [INST] 2015-05-22 11:39:44 +0000 Debug: - selectValue is not supported on a picker with undefined values
info: [debug] [INST] Instruments Trace Complete (Duration : 250.839081s; Output : /tmp/appium-instruments/instrumentscli0.trace)
info: [debug] [INSTSERVER] Instruments exited with code 0
info: [debug] Cleaning up after instruments exit
info: [debug] Instruments exited unexpectedly
info: [debug] Shutting down command proxy and ignoring any errors
info: [debug] Closing socket server.
info: [debug] Instruments socket server was closed
info: [debug] Stopping iOS log capture
info: [debug] Reset not set, not ending sim or cleaning up app state
info: [debug] We were in the middle of processing a command when instruments died; responding with a generic error
info: [debug] Cleaning up appium session
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“Instruments died while responding to command, please check appium logs”,“name”:“UnknownError”,
“origValue”:“Instruments died while responding to command, please check appium logs”},“sessionId”:null}
info: <-- POST /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/element/0/value 500 2491.327 ms - 230
info: --> GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/source {}
info: <-- GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/source 404 1.061 ms - 40
info: --> GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/orientation {}
info: <-- GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/orientation 404 0.963 ms - 40

info: --> GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/screenshot {}
info: <-- GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/screenshot 404 0.996 ms - 40
info: --> GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/contexts {}
info: <-- GET /wd/hub/session/35913ec2-af44-453b-a37d-fe988f104193/contexts 404 0.928 ms - 40

Hi Jipps
I am trying to set the network by using below code
some times its working fine to set a Wi-Fi
some times it showing error

actually when i use the method runappinbackground app moving to background and and i can able to view settings in Iphone and the code working fine but some times app get relaunch and the settings r not visible and the above code get fail

At Last find the solution app and settings of IPhone should not in same screen.

and while launching the app we need to make sure iphone settings is visible


I try 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:

//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)+"]");

Hi All,

In My case I can not use sendkey or set value because in my wheel value is not static. Its change on run time.

Please suggest me can I select the value on the basis of ID or index.

any input will be appreciated.

I’m having a similar problem. The 10 values in the pickerWheel are dates like:
Wed (July 20)
Thu (July 21)

Since these values change every day, I’m looking for some kind of solution where I can pick “the 2nd value”, etc. Any simple solution, without writing a function that gets the current day, date, formats it, etc?

why cant you get just get the current date, thats what i do, but before i got my platform to use setValue properly i would use the TouchAction class and basically blindly click on the x,y coordinates if the screen never changes in size this could work.

TouchAction ta = new TouchAction((IOSDriver)driver) me X,change me Y).perform()

you can use the precise tap function on the inspector to figure out the location.

Hi @Kyle, TouchAction works, but I want to pick a particular month for doing this I need to scroll the wheel and scrolling is not working in UIAPICKERWHEEEL.

With below code I can successfully pick the particular month but when I perform sendKeys it throws error, please below code and my code snippets:

   MobileElement we = (MobileElement)          

Please See below error stacktrace:
org.openqa.selenium.WebDriverException: - selectValue requires a valid value (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.38 seconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b1534ae328c771e0856c93e187490ca824’, time: ‘2016-03-15 10:43:46’
System info: host: ‘GGNF1882s-MacBook-Pro.local’, ip: ‘’, ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.3’, java.version: ‘1.8.0_74’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{app=/Users/f2849/Desktop/iOS_ipa/Shine27June.ipa, networkConnectionEnabled=false, databaseEnabled=false, deviceName=iPhone 5, platform=MAC, desired={app=/Users/f2849/Desktop/iOS_ipa/Shine27June.ipa, sendKeyStrategy=grouped, platformVersion=9.3, platformName=iOS, deviceName=iPhone 5}, sendKeyStrategy=grouped, platformVersion=9.3, webStorageEnabled=false, locationContextEnabled=false, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS}]
Session ID: b7ca297e-a0ae-4aed-8948-94c406fc20ff
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at io.appium.java_client.DefaultGenericMobileDriver.execute(
at io.appium.java_client.AppiumDriver.execute(
at io.appium.java_client.ios.IOSDriver.execute(
at org.openqa.selenium.remote.RemoteWebElement.execute(
at io.appium.java_client.DefaultGenericMobileElement.execute(
at io.appium.java_client.MobileElement.execute(
at io.appium.java_client.ios.IOSElement.execute(
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(
at com.iOSApp.Shine.Registration_Complete_ThirdScreen.test3_goto_Fill_ProfileInfo(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.testng.internal.MethodInvocationHelper.invokeMethod(
at org.testng.internal.Invoker.invokeMethod(
at org.testng.internal.Invoker.invokeTestMethod(
at org.testng.internal.Invoker.invokeTestMethods(
at org.testng.internal.TestMethodWorker.invokeTestMethods(
at org.testng.TestRunner.privateRun(
at org.testng.SuiteRunner.runTest(
at org.testng.SuiteRunner.runSequentially(
at org.testng.SuiteRunner.privateRun(
at org.testng.SuiteRunnerWorker.runSuite(
at org.testng.TestNG.runSuitesSequentially(
at org.testng.TestNG.runSuitesLocally(
at org.testng.remote.RemoteTestNG.initAndRun(
at org.testng.remote.RemoteTestNG.main(

try this



your setting the TextField that the picker is setting, this just basically bypasses the annoying picker. Just make sure the value is formatted to match the what the picker will set.

Thanks a lot @Kyle for your valuable response, but by above code snippets I can only select current date only.

Please refer screenshot of muy UIAutomator :

Any one having solution for above problem?

I had to delete an table cell and for that I had to perform a swipe gesture. This is in python I am sure there will be similar code for Java.
What I figured out is if you have width/height its easier to perform action.
Get second cell of table.
el = self.driver.find_element_by_xpath("//XCUIElementTypeTable[1]/XCUIElementTypeCell[1]")
Get size
el_size = el.size
print el_size[‘width’]
print el_size[‘height’]
touch = TouchAction(self.driver),375,65).wait(15).move_to(el,225,65).release()

to delete element we need to tap on same location