Xamarin UI test error while Taping element.

XcodXamXcodXam RUMember ✭✭

I detected very strange behavior on Xamarin UI test. The issue is - frameworkcan not tap on some marked elements. This absolutely random problem. Issue may appear on Physical Device or Simulator, Android or iOS. Old or new OS Systems. My Test Scenario :

app.WaitForElement(x => x.Marked("IDTransHistory"));
app.Tap(x => x.Marked("IDTransHistory"));
try
        {
            app.WaitForElement(x => x.Marked("Filter"));
            app.Tap(x => x.Marked("Filter"));
        }
        catch (Exception)
        {
            try
            {
                app.Tap(x => x.Marked("Button.Home"));
                app.Tap(x => x.Marked("IDTransHistory"));
            }
            catch (Exception)
            {
                try
                {
                    app.Tap(x => x.Marked("Button.Home"));
                    app.Tap(x => x.Marked("IDTransHistory"));
                }
                catch (Exception)
                {
                    app.Tap(x => x.Marked("Button.Home"));
                    app.Tap(x => x.Marked("IDTransHistory"));
                }
            }
        }

VS Log :

[5/18/2018 12:57:16 PM Informational] ------ Run test started ------
[5/18/2018 12:57:16 PM Informational] NUnit VS Adapter 2.0.0.0 executing tests is started
...
[5/18/2018 12:57:56 PM Informational] Waiting for element matching Marked("IDTransHistory").
[5/18/2018 12:58:03 PM Informational] Using element matching Marked("IDTransHistory").
[5/18/2018 12:58:04 PM Informational] Tapping coordinates [ 532, 1114 ].
[5/18/2018 12:58:05 PM Informational] Waiting for element matching Marked("Filter").
[5/18/2018 12:58:08 PM Informational] Using element matching Marked("Filter").
[5/18/2018 12:58:08 PM Informational] Tapping coordinates [ 684, 96 ].
[5/18/2018 12:58:24 PM Informational] Error while performing Tap(Marked("Date.Start"))
Exception: System.Exception: Unable to find element. Query for Marked("Date.Start") gave no results.
   at Xamarin.UITest.SharedApp.FirstWithLog[T](T[] results, ITokenContainer tokenContainer)
   at Xamarin.UITest.Android.AndroidApp.<Tap>c__AnonStoreyB.<>m__0()
   at Xamarin.UITest.Utils.ErrorReporting.With(Action func, Object[] args, String memberName)
[5/18/2018 12:58:24 PM Informational] Waiting for element matching Marked("Filter").
[5/18/2018 12:58:28 PM Informational] Using element matching Marked("Filter").
[5/18/2018 12:58:28 PM Informational] Tapping coordinates [ 684, 96 ].
[5/18/2018 12:58:32 PM Informational] Using element matching Marked("Date.Start").
[5/18/2018 12:58:32 PM Informational] Tapping coordinates [ 71, 298 ].
[5/18/2018 12:58:35 PM Informational] Using element matching Text("2018").
[5/18/2018 12:58:35 PM Informational] Tapping coordinates [ 139, 228 ].

Ok, as you can see the element marked Filter was using -> Tapping coordinates [ 684, 96 ]. That's mean that element is exist on monitor. But first time this not worked. I use Nunit 3.10 and Xamarin UI Test 2.24. This issue can arises on random Device - iOS or Android, Emulator or Physical. Current test was on Samsung sm a310f. I caught, this error many times. I don't know is this bug of Xamarin UI test or may be Calabash. Maybe Calabash is more stable ? or may be Xamarin.Forms is fail.

Answers

  • inikityukinikityuk Member

    From documentation:

    Xamarin.UITest requires NUnit 2.6.3 or 2.6.4 to run tests. Xamarin.UITest is not compatible with NUnit 3.x.

    That might be your problem.

    I would also check if:

    Tapping on "Filter" - doesn't cause any layout changes(animations for example) -> pause might help in this case.

    Changed the element ID from "Date.Start" to something without dot(.), like "StartDate"

Sign In or Register to comment.