Forum Discussion

panka152's avatar
panka152
Contributor
13 years ago

How to control scroll bar movement

Hi,



I am writing VB script for web based application where a tree view folder structure is there and images are stored in it year/month/day hierarchy.

I used for loop to expand the tree structure, it works fine until the scroll bar comes, and when it come it stuck there.



There are functions appears in code completion window I don't know how to use them, nothing is mentioned in test complete help.

Can anyone help in to understand this functions.

1. ScrollintoView()

2. Mousewheel()



I have tried some methods like....scrollbar.keys("[Home]"), scrollbar.keys("[End]"), scrollbar.keys("[Down] [Down]")...it works for few more and then again stuck.



The tree has many folders/ sub folders and around 3000 to 4000 images are there under hierarchy.

I need a method which should gel up with the click event and should control the scroll bar movement simultaneously.
  • Hi,



    nothing is mentioned in test complete help


    Probably, this is because the methods you're trying to find in TC's help are native web methods. Scripts can call them, but they're not described in the help because they're no related to TC.



    Anyway, when you need to scroll a web page element to make it visible, scrollIntoView usually helps.
  • Hi,

    I have used the method like this: 

    TestObj.ScrollIntoView(False)

    now it always focus on the last element of the tree.

    Thanks for your kind help.
  • ThWatcher's avatar
    ThWatcher
    Occasional Contributor
    Hi.



    I don't know if this will be of any help to you in your situation, but I had a similar problem with a list box. 



    My list box had many items that were not in view, but that I needed to click on in a 'click and drag' test.

    I found that using the following command had the side effect of moving the scroll bar and bringing the desired item into view.

    Of course, this assumes you know the names of items in your tree or that you can retrieve the names of items in your tree.



     // Click the desired item.  This brings the item into view in the list box.

       TargetDialog.Window("SysListView32", SourceListName).ClickItem(ItemName);



    where:

    'SourceListName' is the name of the list box.

    'ItemName' is the name of the item to be clicked in the list box.


  • Hi Rickie,

    I found this method very useful and giving desired result.

    What I done is, mapped the ' +' sign in a tree and used FOR loop to click every node and its child nodes.

    I always put 0 for click item like this......TestObj.clickitem(0)





    In your case if + sign is not there, use a common properties of list view objects and use 'find all' method and use that object in a script to click the objects in list box..

    Previous to this I have used TestObj.MouseWheel(i) which will move the scroll bar with reference to click events.