ScrollDownTo how it works? RRS feed

  • Question

  • User365517 posted

    Hi! I'm creating my test code for my app (Android). I need to scroll view to tap on input fields which have id and class but the method DragCoordinates() not works really good on my case, because I'm testing on a lot of different devices with different size. I need methods which scroll until a particular element is visible, for example my input field with some id. I found ScrollDown and ScrollDownTo but I didn't understand how they work, for example their arguments? Can someone give me some example how to use them??? thankyou

    Thursday, February 15, 2018 9:40 AM

All replies

  • User324818 posted

    Hey there, so here is my android specific usage of it:

                        toQuery: c => c.Marked("ButtonIdentifier"),
                        withinQuery: c => c.Marked("ScrollViewIdentifier"),
                        strategy: ScrollStrategy.Programmatically,
                        timeout: new TimeSpan(0, 0, 60));

    so the toQuery is the control of which you want to find and the withinQuery is the layout or scrollable control that is is within.

    Now this only scrolls down to this control so your will still need to tap the button/control.

    Also, incase you are unsure if the control is present on the screen in the first place, I also recommend doing a quick check to see if the button/control you want to find is on the screen to begin with, so here is an example of my implementation of it for tapping buttons

            public void Tap()
                // Hide keyboard so more elements are visible on the screen
                // if the control is on the screen, skip scrolling steps
                if (app.Query(a => a.Marked("ButtonIdentifier")).Length != 1)
                    // If the button is not visible, scroll up
                    app.ScrollToVerticalStart(c => c.Class("LockableScrollView"));
                    // Once at the top, search for the element, scrolling down in the process
                        toQuery: c => c.Marked("ButtonIdentifier"),
                        withinQuery: c => c.Class("LockableScrollView"),
                        strategy: ScrollStrategy.Programmatically,
                        timeout: new TimeSpan(0, 0, 60));
                // Tap the element
                app.Tap(c => c.Marked("ButtonIdentifier"));
    Tuesday, February 20, 2018 2:26 AM