Problem with IOSPicker

Ask general questions here.
stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Problem with IOSPicker

Post by stapes » Tue Nov 24, 2015 12:07 pm

I am running a test using Ranorex 5.4.3 on an iPad.

It is mostly going OK, but I have an IOSPicker field which is causing me grief.

If I make my selection manually, it works fine.

If I do it in the automation, you can see the selection being made, and the Done button clicked, but the field reverts to a different value to that selected.

This is some code that does the selection. It is based on recordings.

Code: Select all

if(repo.RichardPullinIPad.DeliveryInfo.Exists (1000))
        	{
        		Report.Log(ReportLevel.Info, "Invoke Action", "Invoking Select() on item 'RichardPullinIPad.Delivery'.", repo.RichardPullinIPad.DeliveryInfo);
        		
        		repo.RichardPullinIPad.Delivery.Select();
        	}
        	else
        	{
        		if(repo.RichardPullinIPad.Delivery1Info.Exists (1000))
	        	{
	        		Report.Log(ReportLevel.Info, "Invoke Action", "Invoking Select() on item 'RichardPullinIPad.Delivery1'.", repo.RichardPullinIPad.Delivery1Info);
	        		
	        		repo.RichardPullinIPad.Delivery1.Select();
	        	}
        	}
One small thing to note, the value in the field changes when I scroll down the picker manually.

It doesn't do this when I use .Select()

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Problem with IOSPicker

Post by krstcs » Tue Nov 24, 2015 5:40 pm

The problem is the Select(). It doesn't fire the events like a click/touch, which means you have issues like this where the element's visual changes, but the actual data binding is not exercised, so the true value doesn't change.

If you are going to invoke on an element then you will probably have to manually fire any events that are attached to it.


My suggestion is to use Touch actions instead.
Shortcuts usually aren't...

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Problem with IOSPicker

Post by stapes » Tue Nov 24, 2015 6:29 pm

I tried using .Touch();

It causes the App to crash - and so did .Click() !

The recorder records it as a Select().
Last edited by stapes on Tue Nov 24, 2015 6:59 pm, edited 1 time in total.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Problem with IOSPicker

Post by krstcs » Tue Nov 24, 2015 6:39 pm

Note: I don't use Ranorex for mobile testing, but...


If your app crashes when you perform a Press() action on an element, I would think that is an app issue, not a Ranorex issue. The Press() action has been used by many people on the forums for a while now and it I haven't seen any of them say that it causes their apps to crash.

I would try to get one of your devs to help you debug the app while using Ranorex (especially the Press() action) against it and see if they can figure out where the crash is. Just because it doesn't crash when you don't use Press() doesn't mean there isn't a real bug in the app. The Ranorex integration may just be bringing it out while it is hidden otherwise (a hidden bug is STILL a bug, and one that crashes the system should really be fixed).
Shortcuts usually aren't...

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Problem with IOSPicker

Post by stapes » Tue Nov 24, 2015 6:59 pm

It is not an Application issue - it works fine when it is used Manually, but it always records as Select(), not Touch or Click. Press() is not even a valid option - compilation error.

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Problem with IOSPicker

Post by stapes » Wed Nov 25, 2015 4:11 pm

I am assuming Select() does not work in iPad.

Touch() works on some fields, but caused a crash when I put it in here, maybe because it is an option in an IOSPicker.

I have temporarily dealt with the problem by pausing execution to let the user select this option manually. This will do for a temporary fix but is not really a satisfactory answer - it will not lend itself to further automation.

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Problem with IOSPicker

Post by stapes » Wed Nov 25, 2015 6:07 pm

I stand corrected.

Select() evidently works in some places and not in others.

I thought I had tracked down the source of the problem, but not so.

I have some instances where it works OK, selecting an item from an IOSPicker.

This particular control was associated with a DisplayWhen property, and I thought that might be the cause of it.

However, after some experiments, I have established that even if I take those DisplayWhen properties away, it still fails on this particular form.

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Problem with IOSPicker

Post by stapes » Wed Dec 02, 2015 11:41 am

Found a work around for this that does the trick, with the help of Ranorex Support.

As krstcs already described , the Select()-method 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.

Here is the final code that worked:

Code: Select all

repo.IOS365Agile.Com365agileEnterprise365AgileTEST.Root.UIPickerView.Swipe(Location.Center, ValueConverter.ArgumentFromString<Ranorex.Core.Recorder.Touch.GestureDirection>("SwipeDirection", "Up (270°)"), ValueConverter.ArgumentFromString<Ranorex.Core.Distance>("Distance", ".5"), ValueConverter.ArgumentFromString<Ranorex.Duration>("SwipeDuration", "500ms"), 0);