xamarin - System.Net.Http.HttpRequestException 异常将在物理设备上运行 xamarin UI 测试

标签 xamarin xamarin.android xamarin.forms ui-testing xamarin.uitest

我创建了一个简单的 Xamarin.Forms(Portable) 项目,并在其中包含 UI 测试项目。但是当我尝试在物理设备中运行测试时,它给了我下面提到的异常。

Test Name:  AppLaunches
Test Outcome:   Failed
Result Message: 
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
  ----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.
Result StandardOutput:  Full log file: C:\Users\Admin\AppData\Local\Temp\uitest\log-2016-10-22_11-04-53-698.txt
Skipping IDE integration as important properties are configured. To force IDE integration, add .PreferIdeSettings() to ConfigureApp.
Android test running Xamarin.UITest version: 2.0.0.1534
Initializing Android app on device ZX1D63GCCL with installed app: co.veloxcore.UITestSample2
Signing apk with Xamarin keystore.
Skipping installation: Already installed.

这是我的项目的链接:XamarinUITest 日志文件:Error Log

最佳答案

您是否正在使用 ModernHttpClient ? 您也可以使用Polly如果你想处理网络异常。 例如:

conferences = await Policy  
      .Handle<WebException>()
      .WaitAndRetry
      (
        retryCount:5, 
        sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
      )
      .ExecuteAsync(async () => await getConferencesTask);

还有AsyncErrorHandler是处理异步异常的好工具

关于xamarin - System.Net.Http.HttpRequestException 异常将在物理设备上运行 xamarin UI 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40188774/

相关文章:

c# - 如何使用函数从sqlite数据库中获取数据?

xamarin - 如何将可观察集合绑定(bind)到 xamarin 中的 flexlayout?

ios - Xamarin 工作室。单点触控。无法在 bundle 中加载 NIB ... 名称

c# - 如何在 Xamarin Android 延迟后运行代码

android - 有人可以真正解释 Resource.Designer.cs 的工作原理吗?

ios - Xamarin:无法在 iOS 9.2.1 设备上运行应用程序

android - 在 SharedPreferences 中保存我的数据库版本

c# - 如何在 MVVM 之后的 Xamarin.Forms 中将数据从 ViewModel 传递到 View 代码?

c# - 从 Xamarin Forms 元素共享代码访问自定义渲染器实例

Xamarin Forms DataTrigger 导致 NullReferenceException