Ranorex spy unable to locate element without scroll

Ask general questions here.
Posts: 2
Joined: Sun Apr 12, 2020 7:58 am

Ranorex spy unable to locate element without scroll

Post by rahulnair87 » Sun Apr 12, 2020 8:38 am

Hi Team,

My next project is using Ranorex and I am trying to learn this using the evaluation version.
Coming to the issue, I am trying to select an item in a e-commerce website that it present like two pages(scroll down) from the home page.

I scrolled down to the element and then located the element in spy as in below screenshot.
Spy1.PNG (51.51 KiB) Viewed 301 times
After this the Spy is always able to highlight the element even if I scroll up or down.

Now, if I close the browser session and launch a new session and navigate to the same page, Spy is unable to locate the item. Please note I have not scrolled down.
Spy1.PNG (51.51 KiB) Viewed 301 times
Does Spy always require me to scroll down to bring the element in focus to re-link the object?

And the second question - How to perform the scroll down until the element is visible and perform the click?
I have searched the forum, and tried the below piece, but the itemAdapter return null if the object is not in focus. Please provide any help possible on this matter.

public static void ScrollToElementAndClick(RepoItemInfo repoInfoElement){

if (repoInfoElement != null){
Ranorex.Unknown itemAdapter = repoInfoElement.CreateAdapter<Ranorex.Unknown>(false);
do {Keyboard.Press("{Next}");
} while (itemAdapter.Visible == false);
Spy2.PNG (46.33 KiB) Viewed 301 times

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

Re: Ranorex spy unable to locate element without scroll

Post by Support Team » Tue Apr 14, 2020 4:12 pm

Hello rahulnair87,

Ranorex has a built-in function that will attempt to ensure the element is visible before performing the actions on it. This means Ranorex if allowed by the technology will automatically scroll to the element so it is visible. I navigated to the webpage in your screenshots and performed a few tests to ensure everything was working fine and could not reproduce the issue you are seeing. If you could please provide some additional information such as:

- Browser including version
- Ranorex snapshot of the browser on the page with the element in question. - https://www.ranorex.com/snapshot

I also witnessed several items changing on the homepage so I would also verify the loafers being tracked are still being displayed on the page.