Page 1 of 1

UIPicker Button 'Done' isn't working

Posted: Sat Jan 23, 2016 1:02 am
by wellingtonsantana
Hello,
I'm trying to select a item from UIPicker. The method Select() works fine, but when I touch the button 'Done' the selection isn't completed. The last value on ListItem still.

This is my code:

public void SelectItemListBox(string elementToFocus, string itemName){

/************************************************************************
* Function : SelectItemListBox(string elementToFocus, string item){
*
* Description : This method select an item from Iphone UI list
*
* Parameters : elementToFocus - Element to touch and make visible the UIPicker
* : itemName - Item to select
*
* Return Type : N/A
*
* Return Value : N/A
*
* Revision History
* Date : Author : Reason/Change
* ---------- : ------------------------- : ------------------------------
* 15/01/2016 : Wellington Santana : Initial Creation
************************************************************************/
try {
Report.Log(ReportLevel.Info, "Select", "Selecting the item " + itemName);
Ranorex.SelectTag element = elementToFocus;
element.Touch();
ListItem item = "/mobileapp[@title='ranorex.RxBrowser']/form//iospicker/list[@accessibilitylabel='Component 0']/listitem[@accessibilitylabel='" + itemName +"']";
item.Select();

Ranorex.Button done = "/mobileapp[@title='ranorex.RxBrowser']/form/container[2]//toolbar/button[@accessibilitylabel='Done']";
done.Touch();

} catch (Exception e) {
Report.Error("Error selecting the item" + itemName + " from element: " + elementToFocus + "");
Console.WriteLine(e.ToString());
Report.Screenshot();
}
}

I'm using Ranorex 5.4.4 and testing in Iphone 5s (IOS 9.2.1).
No errors while executing.

Re: UIPicker Button 'Done' isn't working

Posted: Mon Jan 25, 2016 4:55 pm
by Support Team
Hi wellingtonsantana,

Selecting a value in the UIPicker does unfortunately not fire the corresponding event. This means that you will see a change in the picker element, but the OS does not recognize this change.
A workaround would be using a small swipe action on this picker to fire this event after selecting the item as shown in the following screenshot.
Swipe.png
Please do let me know if this workaround solves the problem on your side.

Regards,
Markus (S)

Re: UIPicker Button 'Done' isn't working

Posted: Tue Jan 26, 2016 2:46 pm
by Fergal
I've experienced similar issues in recorded modules for a mobile device.
Support Team wrote:...Selecting a value in the UIPicker does unfortunately not fire the corresponding event. This means that you will see a change in the picker element, but the OS does not recognize this change....
Would you please have a link to where I could read more about that?

Thanks!

Re: UIPicker Button 'Done' isn't working

Posted: Wed Jan 27, 2016 12:43 am
by wellingtonsantana
Thanks for the quick answer!
The workaround works.
This is the line that I added in my code before the click in button "Done".

IosPicker picker = "mobileapp[@title='ranorex.RxBrowser']/form/container[4]//iospicker";
picker.Swipe(Location.Center, ValueConverter.ArgumentFromString<Ranorex.Core.Recorder.Touch.GestureDirection>("SwipeDirection", "Down (90°)"), ValueConverter.ArgumentFromString<Ranorex.Core.Distance>("Distance", ".1"), ValueConverter.ArgumentFromString<Ranorex.Duration>("SwipeDuration", "1000ms"), 0);