Xamarin UI Test Inconsitent Results

Viewed 693

We are currently running a set of 26 tests. However when running in App Center we are getting inconsistent results.

These are all running off the same codebase. And it always seems to be the same tests that are sometimes failing.

Test Results

We are using x.WaitForElement and a TimeSpan of 10 seconds,

 ApplicationContext.WaitForElement(x =>
           x.Property("Text")
           .Contains(element),
           timeout: TimeSpan.FromSeconds(10));

Description of error:

System.Exception : Error while performing WaitForElement(Property("Text").Contains("Services"), "Timed out waiting for element...", 00:00:10, null, null)  
----> System.TimeoutException : Timed out waiting for element...  
at Xamarin.UITest.Utils.ErrorReporting.With[T] (System.Func`1[TResult] func, System.Object[] args, System.String memberName) [0x0005b] in <b407387d5472492e9a5a9fb5ff2a9418>:0   
at Xamarin.UITest.Android.AndroidApp.WaitForElement (System.Func`2[T,TResult] query, System.String timeoutMessage, System.Nullable`1[T] timeout, System.Nullable`1[T] retryFrequency, System.Nullable`1[T] postTimeout) [0x00032] in <b407387d5472492e9a5a9fb5ff2a9418>:0   
at Cashoo.AutomationTests.Base.BasePage.WaitForAnElementToPresent (System.String element) [0x00036] in <86d386ec5946400cb6c19f52c8ea595c>:0   
at Cashoo.AutomationTests.TestsPerPage.DashboardPageTests.ClickOnChooseCashback_ReturnsServicesPage () [0x00016] in <86d386ec5946400cb6c19f52c8ea595c>:0  
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)  
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <48b95f3df5804531818f80e28ec60191>:0 --TimeoutException  
at Xamarin.UITest.Shared.WaitForHelper.WaitForAny[T] (System.Func`1[TResult] query, System.String timeoutMessage, System.Nullable`1[T] timeout, System.Nullable`1[T] retryFrequency, System.Nullable`1[T] postTimeout) [0x0001d] in <b407387d5472492e9a5a9fb5ff2a9418>:0   
at Xamarin.UITest.Android.AndroidApp+<>c__DisplayClass86_0.<WaitForElement>b__0 () [0x00054] in <b407387d5472492e9a5a9fb5ff2a9418>:0   
at Xamarin.UITest.Utils.ErrorReporting.With[T] (System.Func`1[TResult] func, System.Object[] args, System.String memberName) [0x0000e] in <b407387d5472492e9a5a9fb5ff2a9418>:0

Any Ideas will be gratefully appreciated.

Extra Info:

1) Xamarin.UiTest v2.2.5

2) Android v7.1.2

3) Code snippet:

//CTOR
public DashboardPageTests(Platform platform)
{
        this.platform = platform;
        ApplicationContext = AppInitializer.StartApp(platform);
        phoneNumberPage = new PhoneNumberPage();
        passwordPage = new PasswordPage();
        phoneNumberPage.EnterPhoneNumberAndClick("07510000000");
        passwordPage.EnterPasswordAndClickSignIn("A123456a");
}

[Test]
public void ClickOnChooseCashback_ReturnsServicesPage()
{
    //Act
    ApplicationContext.WaitForElement(x =>
       x.Property("Text")
       .Contains("Dashboard"),
       timeout: TimeSpan.FromSeconds(10));
    dashboardPage.ClickOnChooseCashback();
    ApplicationContext.WaitForElement(x =>
       x.Property("Text")
       .Contains("Services"),
       timeout: TimeSpan.FromSeconds(10));
    var elementPresent = ApplicationContext.Query("Services");
    //Assert
    Assert.IsTrue(elementPresent.Any(), "Services text is not visible.");
    servicesPage.ClickOnBackButton();
}
0 Answers
Related