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
Scroll until you spot the desired element
Re: Scroll until you spot the desired element
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:Hope this helps?
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));
}
}
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 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
Re: Scroll until you spot the desired element
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
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
Re: Scroll until you spot the desired element
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
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 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
Re: Scroll until you spot the desired element
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
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
Re: Scroll until you spot the desired element
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?
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 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
-
- Posts: 1
- Joined: Fri Apr 24, 2020 1:58 pm
Re: Scroll until you spot the desired element
the below code works
[UserCodeMethod]
public static void ScrollToElement(RepoItemInfo ScrollElement, RepoItemInfo ElementToFind)
{
if (!ElementToFind.Exists(500))
{
do
{
ScrollElement.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 (!ElementToFind.Exists(500));
}
}
[UserCodeMethod]
public static void ScrollToElement(RepoItemInfo ScrollElement, RepoItemInfo ElementToFind)
{
if (!ElementToFind.Exists(500))
{
do
{
ScrollElement.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 (!ElementToFind.Exists(500));
}
}