Forum Xamarin Test Cloud (Read Only)
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 confirm that a Switch has changed state, using WaitFor or WaitForElement?

Apologies for the newbie question... I have the code below that taps on a Switch if it is not already in the desired state. What I would like to do, is to add a WaitFor operation after doing the tap to confirm that the Switch does actually change state as a result of the tap. I want to use a WaitFor-style operation rather than just perform another Query to allow it some time to change state. I'm sure it cannot be that much different in syntax to the Query shown below, but I'm not quite sure how to do it. Can anybody help please?

        AppResult[] matches = app.Query(styleIdForControl);
            matches.Length == 1,
            String.Format("WaitForElement for the '{0}' switch using Marked returned a number of matches other than 1", controlName));

        if (app.Query(c => c.Marked(styleIdForControl).Invoke("isChecked").Value<bool>()).First()
            != expectedValue)

            // TODO - check that the switch does change state, using WaitFor or WaitForElement with expectedValue


Best Answer


  • JohnHardmanJohnHardman GBUniversity admin

    @MalcolmSmith - Many thanks. Very helpful, and gives me the template to follow for other bits later on. Thanks, John H.

Sign In or Register to comment.