Xamarin UI测试结果不一致

时间:2018-09-06 13:01:02

标签: android xamarin.forms visual-studio-app-center xamarin.uitest

我们目前正在运行26个测试集。但是,在App Center中运行时,我们得到的结果不一致。

这些都在同一代码库上运行。而且似乎总是相同的测试有时会失败。

Test Results

我们使用的x.WaitForElement和TimeSpan为10秒,

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

错误说明:

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

任何想法都会感激不尽。

其他信息:

1)Xamarin.UiTest v2.2.5

2)Android v7.1.2

3)代码段:

//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 个答案:

没有答案
相关问题