Scroll until you spot the desired element

Ranorex Spy, Recorder, and Studio.
Subhadip
Posts: 9
Joined: Fri Feb 01, 2019 8:57 am

Scroll until you spot the desired element

Post by Subhadip » Sat Jul 13, 2019 5:58 am

Hi,

Here is a scenario I am trying to automate.
I have an element e in my ios app.
And that is dynamically placed in the screen.
Sometime we get the element on the top of the screen, but sometime it goes down.

So,I will have to scroll and check if the element is there or not, if its there I have to click on it.
How do I achieve this.

Thank you,
Subhadip

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4967
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Scroll until you spot the desired element

Post by odklizec » Mon Jul 15, 2019 8:38 am

Hi,

I'm doing something like this in one of my Android tests, where some elements are loaded in memory only if they are scrolled to the visible area of screen. Here is a sample code:

Code: Select all

public static void ScrollListToElement(RepoItemInfo viewScrollElement, RepoItemInfo sequenceElement)
{
    if (!sequenceElement.Exists(10000))
    {
        do 
        {
            viewScrollElement.CreateAdapter<Ranorex.Unknown>(false).Swipe(Location.Center, ValueConverter.ArgumentFromString<Ranorex.Core.Recorder.Touch.GestureDirection>("SwipeDirection", "Up (270°)"), ValueConverter.ArgumentFromString<Ranorex.Core.Distance>("Distance", "200"), ValueConverter.ArgumentFromString<Ranorex.Duration>("SwipeDuration", "500ms"), 0);
            Delay.Milliseconds(500);
        } while (!sequenceElement.Exists(10000));
    }
}
Hope this helps?
Last edited by odklizec on Tue Jul 16, 2019 1:14 pm, edited 2 times in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Subhadip
Posts: 9
Joined: Fri Feb 01, 2019 8:57 am

Re: Scroll until you spot the desired element

Post by Subhadip » Tue Jul 16, 2019 12:06 pm

Hi,

Thank you so much for your reply.
I am new to user code . So, having difficulty in understanding how to declare a repo element in my code and what are Adopters and how to use them.
Could you please help me on that.

Thank you,
Subhadip

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4967
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Scroll until you spot the desired element

Post by odklizec » Tue Jul 16, 2019 1:19 pm

Hi,

Check my previous post. I just updated the sample code, with method declaration. Basically, you must add this method to recording of your choice (as a code action) and link repository elements for scrolable view item and element you want to find. Code should do the rest of voodoo magic ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Subhadip
Posts: 9
Joined: Fri Feb 01, 2019 8:57 am

Re: Scroll until you spot the desired element

Post by Subhadip » Wed Jul 17, 2019 7:25 am

Hi,

Thank you for your response.
I tried putting in the script and associating two elements with it to use that as a Code action.
But, its not working, because if (!sequenceElement.Exists(10000)) condition is returning false even when the element is not visible in the screen.

Can you help me out on this.

Thank you,
Subhadip

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4967
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Scroll until you spot the desired element

Post by odklizec » Wed Jul 17, 2019 7:28 am

Hi,

I'm afraid, without seeing, at very least, a Ranorex snapshot (NOT screenshot) of your application and repo xpath, you are using for given element, there is not much anyone here can do or suggest. Could you please share the snapshot and xpath?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration