I detected very strange behavior on Xamarin UI test. The issue is - framework
can 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 don't know is this bug of Xamarin UI test or may be Calabash.
UPD :
Code -
app.ScrollDownTo(x => x.Marked("IDTransHistory"));
app.Tap(x => x.Marked("IDTransHistory"));
app.WaitForElement(x => x.Marked("Filter"));
app.Tap(x => x.Marked("Filter"));
app.WaitForElement(x=>x.Marked("Date.Start"));
app.Tap(x => x.Marked("Date.Start"));
Log -
[5/21/2018 3:05:00 PM Informational] Skipping installation: Already installed.
----
[5/21/2018 3:05:34 PM Informational] Scrolling down to Marked("IDTransHistory")
[5/21/2018 3:05:37 PM Informational] Using element matching Marked("IDTransHistory").
[5/21/2018 3:05:37 PM Informational] Tapping coordinates [ 533, 1114 ].
[5/21/2018 3:05:38 PM Informational] Waiting for element matching Marked("Filter").
[5/21/2018 3:05:40 PM Informational] Using element matching Marked("Filter").
[5/21/2018 3:05:40 PM Informational] Tapping coordinates [ 684, 96 ].
[5/21/2018 3:05:41 PM Informational] Waiting for element matching Marked("Date.Start").
[5/21/2018 3:05:56 PM Informational] Error while performing WaitForElement(Marked("Date.Start"), "Timed out waiting for element...", null, null, null)
Exception: System.TimeoutException: Timed out waiting for element...
at Xamarin.UITest.Shared.WaitForHelper.WaitForAny[T](Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout)
at Xamarin.UITest.Android.AndroidApp.<WaitForElement>c__AnonStorey31.<>m__0()
at Xamarin.UITest.Utils.ErrorReporting.With[T](Func`1 func, Object[] args, String memberName)
[5/21/2018 3:05:57 PM Informational] Query for * gave 46 results.
[5/21/2018 3:05:57 PM Informational] [
{
Run
app.Repl();
and enter tree . You will find the list of UI visible code try there once with your code. If it is working its fine or else use Class and the class name instead of the Marked with the text on the UI. For instance:-app.Tap( a => a.Class("classs-name"));
// if you have same class name used use index for that asapp.Tap( a => a.Class("classs-name").index(value));