How to scroll using C# code?

Ranorex Spy, Recorder, and Studio.
zivshapira
Posts: 14
Joined: Mon Mar 18, 2013 1:06 pm

How to scroll using C# code?

Post by zivshapira » Mon Mar 18, 2013 1:14 pm

Hi

I am trying to scroll to a value in a drop-down menu and select it using C# code. The code is Flex.

I am able to select the value (VPAID) successfully, if it is visible when i click on the drop-down, but when it is not visible - the selection fails. I am using this method:

Element.FindSingle<Ranorex.Text>(".//text[@Text='VPAID']").Click();

How do I scroll down using C# code until the value is visble? is there another approach?

Thanks

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to scroll using C# code?

Post by Ciege » Mon Mar 18, 2013 4:37 pm

Easiest way I found is to use keyboard commands... Something like the following... This will work for most any drop list quite reliably.

*) Open the drop down
*) If item is visible in the list, click it
else
*) press HOME key to go to the top of the list
*) While item is not visible
*) Press down arrow
*) if item is visible click it
*) Loop
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

zivshapira
Posts: 14
Joined: Mon Mar 18, 2013 1:06 pm

Re: How to scroll using C# code?

Post by zivshapira » Tue Mar 19, 2013 6:45 am

Thank you :)

mdgairaud
Posts: 87
Joined: Sun Aug 05, 2012 11:59 am
Location: Bilbao, Spain

Re: How to scroll using C# code?

Post by mdgairaud » Wed Mar 20, 2013 4:44 pm

Hi,

For drop-down menu I follow these steps:
  1. 1. Click over it
    2. Simulate pressing the First letter of the list (it forces to select the top element)
    3. Repeat Step 2 with the first letter of the element I need to select.
if it doesn't works, I usually try to click over the element using coordinates


hope it helps.


regards,
Mateo.