UIPicker Button 'Done' isn't working

Mobile Testing, Android App Testing.
wellingtonsantana
Certified Professional
Certified Professional
Posts: 18
Joined: Sat Jan 23, 2016 12:50 am
Contact:

UIPicker Button 'Done' isn't working

Post by wellingtonsantana » Sat Jan 23, 2016 1:02 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: UIPicker Button 'Done' isn't working

Post by Support Team » Mon Jan 25, 2016 4:55 pm

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)
You do not have the required permissions to view the files attached to this post.

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: UIPicker Button 'Done' isn't working

Post by Fergal » Tue Jan 26, 2016 2:46 pm

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!

wellingtonsantana
Certified Professional
Certified Professional
Posts: 18
Joined: Sat Jan 23, 2016 12:50 am
Contact:

Re: UIPicker Button 'Done' isn't working

Post by wellingtonsantana » Wed Jan 27, 2016 12:43 am

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);