Swipe Gesture usage - any Rule of Thumb to follow?

Mobile Testing, Android App Testing.
gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Swipe Gesture usage - any Rule of Thumb to follow?

Post by gilbar16 » Fri Feb 12, 2016 11:18 pm

Hi,

The AUT running on a mobile device is partially showing a Log In button, for example, when in Portrait mode.
Using the EnsureVisible() won't do anything and my guess is that because the button is already visible although not completely. This works fine when I switch to Landscape mode.

So the next Action I can think of is the use of Swipe Gesture.
Assuming it works, is there any Rule of Thumb or Best Practice for setting the values for Distance and Swipe Duration parameters so that your script will run successfully in both Portrait and Landscape modes?

If I use the default value .5 for Distance, sure it works well in Portrait mode since it was partially visible already but if in Landscape mode, then it isn't enough to ensure the button to be visible.

Thanks.
Gilbert

zivshapirawork
Posts: 65
Joined: Wed Sep 24, 2014 7:47 am
Location: Israel

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by zivshapirawork » Sun Feb 14, 2016 12:15 pm

Hi

Try a swipe in a loop until it is visible. Maybe that can help you.

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by tvu » Mon Feb 15, 2016 6:13 pm

I have found that EnsureVisible() doesn't work reliably on mobile device. Also, the Visible attribute is not reliable as well. I have found two reasons for this:
  • 1. The UI is built on layers. The item's Visible attribute might be true, but there is a layer in front of that item that is keeping it from view.
    2. The dimensions of tables, containers, etc... might be larger than the physical size of the screen. So a button contain in that table might be off screen, but the Visible attribute value might be true.
In our app, we have a vertical navigation menu that you can scroll. It has a nested structured like this:
  • 1. Main container
    • 2. Table
      • 3. Table Wrapper container
        • 4. List of containers for each menu item
Don't ask me why it's like that... it just is. The height of the Main Container (#1) is exactly the height of the physical screen. The height of Table (#2) actually extends higher and lower than the physical screen. This caused issue because the Menu Item container (#4) would be listed as Visible, but it is actually off screen. Even if it is on screen, it might not be fully displayed like the issue you are facing.

I tried swiping on the Menu Item container, but I was running into random failures because the container wouldn't be visible or fully visible. I couldn't perform a swipe on the Table as well because the dimensions height was bigger than the screen. I eventually settled on performing a swipe on the Main container and that worked very well.

I wrote a custom IsFullyVisible() method that would return whether the Menu Item was fully visible or not based on it's location and height. If it's not fully visible then I would perform a swipe on the Main Container then recheck if it's fully visible.

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by gilbar16 » Mon Feb 15, 2016 6:50 pm

Hi tvu,

Wow, lots of extra work just to bring an object to be fully visible.

I think what would be nice (I probably should submit an enhancement request to Ranorex) to see happen with EnsureVisible() method/function is:
If the target object is fully visible already, EnsureVisible() should do nothing.
If the target object is only partially visible or not visible at all, EnsureVisible() should scroll the object into view fully.

Note: I was told to use the Swipe Gesture on a DOM object level and that seems to work. The only issue though is back to the Portrait and Landscape modes. Sometimes the swipe has to be done only one time, sometimes two or more times when in Landscape. If the EnsureVisible() is working well, I guess we won't need to use Swipe Gesture.

Wouldn't it be nice if Swipe Gesture uses an argument for the target object to be scrolled fully into view?

Thanks for your input.
Gilbert

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by tvu » Mon Feb 15, 2016 7:04 pm

The loop that zivshapirawork suggested with a custom IsVisible() method should do that trick for you. That will solve your orientation problem.

In my case, I wrote an auto navigation custom code. I simply provide the Menu Item I want to click on and it will bring the item to view and click on it. That would not be possible if I didn't use a loop and the custom IsVisible() method.

Don't be discourage. It's not that much extra work. The IsVisible() method is literally four IF statements that checks the following:
  • 1. Does the item exist? No, return false.
    2. Does it start off screen? Yes, return false.
    3. Does the width extend off screen? Yes, return false.
    4. Does the height extend off screen? Yes, return false.

    Else return true.

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

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by krstcs » Mon Feb 15, 2016 7:10 pm

Gilbar16,

That is actually exactly what Ensure Visible does, when it can.

The problem is that the methods used to do it may not work on some apps, depending on how the app is developed and what framework/platform it is built on.

Unfortunately there isn't much Ranorex can do about it.

And Ranorex allows you to write any .NET methods you need, so you could create your own swipe-until-in-view method to do what you need. We really can't and shouldn't expect Ranorex to implement EVERY possible use-case for us. They are not building the use-cases, but the framework to create the use-cases, which is where we, the users, come in.
Shortcuts usually aren't...

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by gilbar16 » Tue Feb 16, 2016 12:57 am

tvu: Not discourage at all. When you have so many projects lined up, you just wanted to wish that methods/functions built-in or missing should be there and working properly. If you have all the extra time to write your own codes, sure why not keep writing them.

Regarding the EnsureVisible(), I really think it is a bug or that Ranorex should be able to make a change so it will work better.
Example:
In Portrait mode, the Login button is partially shown on the screen; the caption or label is nowhere to be seen. EnsureVisible() action won't do a thing when issued.

In Landscape mode, the EnsureVisible() works perfectly as it scrolls the Login button properly and fully.
Run it again but, this time scroll the Login button to show a tiny portion of it just like in the Portrait mode.
As expected, EnsureVisible() action did not do a thing because to Ranorex tool, the object is already visible even though issuing a Touch action to touch 0,0 or Upper Left of the button won't work. If you take a screenshot after EnsureVisible(), you won't even know what that piece of image is since it did not get scrolled.

If Ranorex can determine that the button is only partially visible (let's say 1% to 5% of its total picture), I think Ranorex should treat this similar to it being invisible so that it can be scrolled into view.
Other tools like SilkTest does this nicely.

Built-in functions/methods in Ranorex is a lot less compared to the other test tools.
Ranorex has plenty of room to keep adding new and improved functions/methods if they want to compete with the other tools for years to come! :>

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

Re: Swipe Gesture usage - any Rule of Thumb to follow?

Post by Support Team » Thu Feb 18, 2016 3:04 pm

Hello,

We are already aware of the fact that the EnsureVisible() action does not work properly on mobile devices if the element is visible partially.

Unfortunately, I can't give you detailed information on when the issue will be fixed.

Thank you for your understanding.

Sincerely,
Johannes