Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to scroll whole page in Xamarin UI Test, Specflow

I have tried the following code but it not works

pageScrollSteps.cs :

app.ScrollTo("autoid3", withinMarked: "autoid1", strategy: ScrollStrategy.Auto, timeout: new TimeSpan(0, 1, 0));
=> scroll up to only 4 line. not scroll whole page

app.ScrollDown("autoid2", strategy: ScrollStrategy.Auto, swipePercentage: 0.67, swipeSpeed: 500, withInertia: true);
----> Message: System.Exception : Error while performing ScrollDown(Marked("autoid2"), Auto, 0.67, 500, True)
----> System.Exception : Unable to scroll, no element were found by query: Marked("autoid2")

app.ScrollDownTo(c => c.Marked("autoid2"), c => c.Marked("ScrollView"));
----> Message: System.Exception : Error while performing ScrollDownTo(Marked("autoid2"), Marked("ScrollView"), Auto, 0.67, 500, True, null)
----> System.Exception : Unable to scroll, no element were found by query: Marked("ScrollView")

app.ScrollUp(c => c.Text("This is last of scroll"), strategy:ScrollStrategy.Auto, swipePercentage:0.67);
----> Message: System.Exception : Error while performing ScrollUp(Text("This is last of scroll"), Auto, 0.67, 500, True)
----> System.Exception : Unable to scroll, no element were found by query: Text("This is last of scroll")

app.ScrollUpTo("autoid3", strategy: ScrollStrategy.Gesture, timeout: new TimeSpan(0, 1, 0));
----> Message: System.Exception : Error while performing ScrollUpTo(Marked("autoid3"), null, Gesture, 0.67, 500, True, 00:01:00)
----> System.Exception : Timeout before element was found

If anyone having a solution to scroll the whole page please let me know.

Best Answer

  • chetanpardeshichetanpardeshi Member ✭✭
    Accepted Answer

    Thanks, Jarvan for your comments.

    I have tried to change the parameter withinMarked but the whole page not working.

    for temporary I have repeat ScrollDown method's to scroll whole page & it works.

    app.ScrollDown(withinMarked:"autoid1", strategy : ScrollStrategy.Gesture, swipePercentage : 0.99, swipeSpeed : 500, withInertia : true);
    app.ScrollDown(withinMarked: "autoid1", strategy: ScrollStrategy.Gesture, swipePercentage: 0.99, swipeSpeed: 500, withInertia: true);

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    IApp.ScrollTo will make the screen scroll until an element that matches the toMarked is shown on the screen.

    In your code, the method scrolls to the 4th line. Try to change toMarked string to be marked to the last line or nothing.

    app.ScrollTo("autoid3", withinMarked: "autoid1", strategy: ScrollStrategy.Auto, timeout: new TimeSpan(0, 1, 0));
    

    The IApp.ScrollDownTo and IApp.ScrollUpTo are the same as above..

  • @Jarvan thanks for your comment

    I have tried this
    app.ScrollDownTo("autoid2", withinMarked: "autoid1", strategy: ScrollStrategy.Auto, swipePercentage: 0.99, swipeSpeed: 500, withInertia: true, timeout: new TimeSpan(0, 1, 0));
    => now it scroll to first 26 line but not scroll whole page

    app.ScrollTo("autoid2", withinMarked: "autoid1", strategy: ScrollStrategy.Auto, swipePercentage: 0.99, swipeSpeed: 500, withInertia: true, timeout: new TimeSpan(0, 1, 0));
    => it scroll to first 4 lines only & not scroll whole page

    scrollpage.xaml =>


    Please let me know how to scroll the whole page.

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited November 2019

    The ScrollTo method's second parameter withinMarked is the element to scroll within. The element is ScrollView in your code, the screen scrolls only in ScrollView. Try to set the withinMarked to page layout.

  • chetanpardeshichetanpardeshi Member ✭✭
    Accepted Answer

    Thanks, Jarvan for your comments.

    I have tried to change the parameter withinMarked but the whole page not working.

    for temporary I have repeat ScrollDown method's to scroll whole page & it works.

    app.ScrollDown(withinMarked:"autoid1", strategy : ScrollStrategy.Gesture, swipePercentage : 0.99, swipeSpeed : 500, withInertia : true);
    app.ScrollDown(withinMarked: "autoid1", strategy: ScrollStrategy.Gesture, swipePercentage: 0.99, swipeSpeed: 500, withInertia: true);

Sign In or Register to comment.