UIAPickerWheel value selection

4,375 views
Skip to first unread message

Madhukar Jha

unread,
Mar 11, 2013, 2:29:00 AM3/11/13
to appium-...@googlegroups.com
Hi,
   How would i select a value of UIAPickerWheel control in IPhone using .net.

   var btnUIPicker = driver.FindElementsByTagName("UIAPickerWheel");

Kindly help me to resolve this issue.


Thanks 
Madhukar 

Jonathan Lipps

unread,
Mar 11, 2013, 2:05:52 PM3/11/13
to Madhukar Jha, appium-...@googlegroups.com
Try "pickerwheel" for the tag name. We use mechanic element class names [1].

Jonathan


--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Madhukar Jha

unread,
Mar 13, 2013, 9:23:43 AM3/13/13
to appium-...@googlegroups.com
Thanks for reply. 

I am able to select object pickerwheel but not able to set/select any value in picker wheel. Suppose i have a picker wheel with values of months like Jan, Feb.. etc. i need to select any one the value. I have tried this also:

JSONObject tapObject = new JSONObject();
               tapObject.startX= 0.95;
               tapObject.startY= 0.5;
                tapObject.endX = 0.05;
                tapObject.endY = 0.05;
                tapObject.duration = 1.8;
                tapObject.touchCount = 2;
                Console.WriteLine(JsonConvert.SerializeObject(tapObject));
                JsonSerializerSettings j =new JsonSerializerSettings();
          
                driver.ExecuteScript("mobile: swipe", JsonConvert.SerializeObject(tapObject,Formatting.Indented));
but this approach returning error like "startX and startY parameter does not exist".

FYI: My Dev. language is c#

Thanks 
Madhukar

Jonathan Lipps

unread,
Mar 13, 2013, 2:08:23 PM3/13/13
to Madhukar Jha, appium-...@googlegroups.com
Looks like we'll need an update to Appium to call UIAPickerWheel.selectValue(). I'll report back here when it's done.

Meanwhile, the reason your swipe isn't working may be that the second argument needs to be an array of length one containing the object. So instead of

driver.ExecuteScript("mobile: swipe", <object>)

It should be

driver.ExecuteScript("mobile: swipe", [<object>])

Not sure how to do that in c#.

Jonathan Lipps

unread,
Mar 13, 2013, 3:03:19 PM3/13/13
to Madhukar Jha, appium-...@googlegroups.com
Ok, check out https://github.com/appium/appium/pull/264. Should be merged soon.

The flow goes like this:

* get your picker element (tag name: picker)
* get all the wheels for that picker (tag name: pickerwheel)
* you can list values for that wheel by doing element.getAttribute("values")
* you can set the value by doing element.setValue(myNewValue)
* you can get the current value by doing element.getValue() -- note that this returns the value plus "x of y", where x is index of the value you chose, and y is total options.


On Mar 13, 2013, at 6:23 AM, Madhukar Jha <madhuk...@gmail.com> wrote:

Al Villaflor

unread,
May 2, 2013, 2:54:34 PM5/2/13
to appium-...@googlegroups.com, Madhukar Jha
Does the setValue work?  All I get is an error 'object has no attribute 'setValue'

Al Villaflor

unread,
May 2, 2013, 3:34:18 PM5/2/13
to appium-...@googlegroups.com, Madhukar Jha
Never mind. I was able to figure it out. Looks like you can do element.sendKeys() to set it instead of setValue.
thanks.

Jonathan Lipps

unread,
May 2, 2013, 3:41:13 PM5/2/13
to Al Villaflor, appium-...@googlegroups.com, Madhukar Jha
Yeah exactly. sendKeys uses setValue under the hood. This is a JSONWP wart.

wa...@edmodo.com

unread,
Oct 10, 2013, 3:06:45 PM10/10/13
to appium-...@googlegroups.com, Al Villaflor, Madhukar Jha
Sorry to continue on this thread.  I just have question on how you can pick the items in Ruby

I use something like this but did not seem to work.
 driver.find_element(:xpath, '//picker[1]/pickerwheel[1]').select_value "https://mycompany.com/v2.4/. 2 of 9"

BTW, seems no way to record this pick method in the Recorder?
   

Pooja Shah

unread,
Mar 25, 2014, 2:47:15 AM3/25/14
to appium-...@googlegroups.com, Al Villaflor, Madhukar Jha
Hi Jonathan,

(Im using - Appium + Webdriver +Java+IOS 7)  driver.findElement(By.xpath(" //window[1]/picker[1]/pickerwheel[1]").sendKeys("1. 1 of 6");

 While getAttribure returns the correct attribute but while sending that attribute as keys it throws error 

But it fails with this error
Returning By locator: By.xpath: //window[1]/picker[1]/pickerwheel[1] [
[ INFO] [main] TC-1234613:
==================== Test Method::1::verifyFlightsSearch tcid=1234613 Failed at 25-03-2014 00:02:25 [Elapsed Time = 03:10] ==================== [runTestListeners::Invoker.java:1883]
[ERROR] [main] TC-1234613:org.openqa.selenium.WebDriverException: An error occurred while executing user supplied JavaScript. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 162 milliseconds
Build info: version: '2.39.0', revision: '14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: '2013-12-16 13:18:38'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.7.0_51'


Though Appium logs looks fine:

Pushing command to appium work queue: "au.getElementByXpath('\\/\\/window[1]\\/picker[1]\\/pickerwheel[1]')"

debug: Request received with params: {"using":"xpath","value":"//window[1]/picker[1]/pickerwheel[1]"}
debug: Sending command to instruments: au.getElementByXpath('\/\/window[1]\/picker[1]\/pickerwheel[1]')

info: [INSTSERVER] Sending command to instruments: au.getElementByXpath('\/\/window[1]\/picker[1]\/pickerwheel[1]')

info: [INSTSERVER] Socket data received (61 bytes)

info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":{"ELEMENT":"5"}}
info: Responding to client with success: {"status":0,"value":{"ELEMENT":"5"},"sessionId":"ca8d53f8-74ba-4cf2-a2d7-e8482fe48335"}

POST /wd/hub/session/ca8d53f8-74ba-4cf2-a2d7-e8482fe48335/element 200 170ms - 109b

debug: Appium request initiated at /wd/hub/session/ca8d53f8-74ba-4cf2-a2d7-e8482fe48335/element/5/attribute/value

info: Pushing command to appium work queue: "au.getElement('5').value()"

debug: Request received with params: {}
debug: Sending command to instruments: au.getElement('5').value()

info: [INSTSERVER] Sending command to instruments: au.getElement('5').value()

info: [INSTSERVER] Socket data received (57 bytes)

info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":0,"value":"1. 1 of 6"}
info: Responding to client with success: {"status":0,"value":"1. 1 of 6","sessionId":"ca8d53f8-74ba-4cf2-a2d7-e8482fe48335"}
GET /wd/hub/session/ca8d53f8-74ba-4cf2-a2d7-e8482fe48335/element/5/attribute/value 200 146ms - 96b


What is wrong, please suggest.
Thanks,
Pooja

Pooja Shah

unread,
Mar 25, 2014, 4:11:41 AM3/25/14
to appium-...@googlegroups.com, Al Villaflor, Madhukar Jha
updating

It works directly with normal sendkeys instead of value (1. 1 of 6)

driver.findElement(By.xpath(" //window[1]/picker[1]/pickerwheel[1]").sendKeys("1");  works without issue provided, appium inspector shows the complete xpath till the individual picker wheel.

What made it didnt work was, sometimes, appium inspector doenst comes on picker (still pointing to background) and so not selectable which gives impression that "picker" is a different element and has to be handled different way. Hope it gets solved in coming updates.
Thanks
Pooja

Vignesh Radhakrishna

unread,
May 30, 2014, 9:02:22 AM5/30/14
to appium-...@googlegroups.com
i need to select the value "USA" whereas at the very first time when i inspect it is showing "United States" initially , only if i scroll to the next element say "US"  it is visible. i tried to take the tag name of the pickerwheel as follows , driver.findelement(By.tagname("pickerwheel")).getAttribute("value");

It prints me "United States" but i dont know how to go to the next element "US" or "USA". 

Vignesh Radhakrishna

unread,
May 30, 2014, 9:10:10 AM5/30/14
to appium-...@googlegroups.com

Xpath for all the three elements are the same even though.

automated tester

unread,
Jun 26, 2014, 11:56:58 PM6/26/14
to appium-...@googlegroups.com
Im still having issues with selecting a value in a pickerwheel. My pickerwheel displays Month Year values like "June 2014" then "July 2014" etc

i did driver.FindElementInTime(By.XPath("//UIAApplication[1]/UIAWindow[2]/UIAPicker[1]/UIAPickerWheel[1]")).GetAttribute("Value"); and i get the value of "June 2014. 1 of 13" which is current month and year

i want to select next month so ive tried both the following:

driver.FindElementInTime(By.XPath("//UIAApplication[1]/UIAWindow[2]/UIAPicker[1]/UIAPickerWheel[1]")).SendKeys("2");
driver.FindElementInTime(By.XPath("//UIAApplication[1]/UIAWindow[2]/UIAPicker[1]/UIAPickerWheel[1]")).SendKeys("July 2014");

but fails and get exception:
System.InvalidOperationException : An error occurred while executing user supplied JavaScript. (UnexpectedJavaScriptError)
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.SendKeys(String text)
   at WebDriver_HotelsCombined.AppiumiOsScreenShotComparison.TEST() in AppiumiOsScreenShotComparisons.cs: line 44

i really need to set the value ""July 2014" how can i do this ?

Anish Joshi

unread,
Jul 1, 2014, 1:06:38 AM7/1/14
to appium-...@googlegroups.com
I'm facing some weird issue, Send keys for setting up the value was working fine now it throws :

Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"Unexpected error in -[UIAPickerWheel_0xaabee50 _spinWheel:], /SourceCache/UIAutomation_Sim/UIAutomation-365.3/Framework/UIAItemElements.m line 358, kAXErrorInvalidUIElement"},"sessionId":"e2e7ef1f-dd10-4357-a693-6bfa843a834f"}
POST /wd/hub/session/e2e7ef1f-dd10-4357-a693-6bfa843a834f/element/0/value 500 1174ms - 361b

can someone explain me this issue or help me rectify it ?

Henit Lax

unread,
Jul 8, 2014, 5:48:22 AM7/8/14
to appium-...@googlegroups.com
Hi,

I had the same issue with date pickers. 

I got a solution to it. I have written a custom method in C#

public void EnterDateOnWheel(IWebElement datePicker, string month, string date, string year)
        {
            Click(datePicker);
            _webDriver.SetContext("NATIVE_APP");
            _webDriver.FindElementsByClassName("UIAPickerWheel")[0].SendKeys(month);
            _webDriver.FindElementsByClassName("UIAPickerWheel")[1].SendKeys(date);
            _webDriver.FindElementsByClassName("UIAPickerWheel")[2].SendKeys(year);
            _webDriver.FindElementByPartialLinkText("Done").Click();
            _webDriver.SetContext("WEBVIEW_1");

        }

here firstly I am clicking on the date which will show the picker widget(if that is called)
change the view
interact with the wheels by sending the values
pressing done
and then going back to the webview


I hope it helps.
Cheers
Henit

Nick Rasputin

unread,
Jul 14, 2014, 9:27:18 AM7/14/14
to appium-...@googlegroups.com
I have the same issue but it only reproduces if picker have two or more wheels, the value of wheel changes only once and then the error above is thrown.  

sebv

unread,
Jul 14, 2014, 12:11:40 PM7/14/14
to appium-...@googlegroups.com
Please post full log (from start to crash) in a link, I've been trying to repro and it seems work fine, will add a unit test moving several picker wheels.

sebv

unread,
Jul 14, 2014, 12:29:35 PM7/14/14
to appium-...@googlegroups.com

Nick Rasputin

unread,
Jul 14, 2014, 1:07:18 PM7/14/14
to appium-...@googlegroups.com
Here's the full log: http://pastebin.com/ZHkeyknG
Reply all
Reply to author
Forward
0 new messages