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.

Selecting a particular element of collectionview in UI test

I am performing UI test for a collection view of items. The number of items in the collection view is dynamic.
The xaml code defining the collectionview is as follows.

By this code(shown as below)
app.Tap(x => x.Marked("VehicleListAutoId").Child());
I was able to select the first element in the collection view. How can I select other element from the collection view?
i.e. I don't want the first element to be clicked, rather I want second, or third element to be clicked.

Answers

  • Scott_BScott_B AUMember ✭✭

    If you are able to name your elements

    void ScrollDownAndTap(string name)
        {
            app.ScrollDownTo(name);
            app.Tap(name);
        }
    

    If you are not (like picking a picture from photos) is it a bit hinky

    app.WaitForElement(c => c.Marked("Photos"), "Timed out", TimeSpan.FromSeconds(15));
            app.TapCoordinates(100, 100);
    
            app.WaitForElement(c => c.Marked("Moments"), "Timed out", TimeSpan.FromSeconds(15));
            app.TapCoordinates(100, 250);
    
  • KashishJainKashishJain Member ✭✭

    Thanks @Scott_B. But how can Ifind the coordinate of the elements in the listview, so that I could write

    app.TapCoordinates(X, Y);

Sign In or Register to comment.