Forum Visual Studio

Xamarin.UITest 2.2.4 start session failed on the first test

daferadafera USMember ✭✭

Hello there,

Since my macOS made me update to XCode 9.3 I had to upgrade Xamarin.UITest from 2.2.2 to 2.2.4.

The problem is that when I run all my tests, every single time the first one fails with the error attached. I think is not a test issue because all tests run correctly on a macOS with XCode 9.2 and Xamarin.UITest 2.2.2. Also if I delete that test, then the next one that is going to be the first one fails with the same error.

Can anyone help me, please? Thank you so much in advance!

1) SetUp Error : UI.Tests.TestDashboardDetailsPage(iOS) Xamarin.UITest.XDB.Exceptions.DeviceAgentException : DeviceAgent start session failed: An error occurred while sending the request ----> System.Net.Http.HttpRequestException : An error occurred while sending the request ----> System.Net.WebException : Error: ConnectFailure (Connection refused) ----> System.Net.Sockets.SocketException : Connection refused at Xamarin.UITest.XDB.Services.iOSDeviceAgentService+c__async141[T].MoveNext () [0x0010e] in <1bd397951f434cd4913ddc08b7bc45af>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at Xamarin.UITest.XDB.Services.iOSDeviceAgentService+c__asyncE.MoveNext () [0x000ba] in <1bd397951f434cd4913ddc08b7bc45af>:0 --- End of stack trace from previous location where exception was thrown --- at Xamarin.UITest.iOS.iOSAppLauncher.LaunchAppLocal (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, System.Boolean clearAppData) [0x00216] in <1bd397951f434cd4913ddc08b7bc45af>:0 at Xamarin.UITest.iOS.iOSAppLauncher.LaunchApp (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Http.HttpClient httpClient, Xamarin.UITest.TestCloud.TestCloudiOSAppConfiguration testCloudAppConfiguration, Xamarin.UITest.Shared.Http.HttpClient testCloudWsClient, Xamarin.UITest.Shared.Http.HttpClient xtcServicesClient, System.Boolean testCloudUseDeviceAgent) [0x0007a] in <1bd397951f434cd4913ddc08b7bc45af>:0 at Xamarin.UITest.iOS.iOSApp..ctor (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration, Xamarin.UITest.Shared.Execution.IExecutor executor) [0x002de] in <1bd397951f434cd4913ddc08b7bc45af>:0 at Xamarin.UITest.iOS.iOSApp..ctor (Xamarin.UITest.Configuration.IiOSAppConfiguration appConfiguration) [0x00000] in <1bd397951f434cd4913ddc08b7bc45af>:0 at Xamarin.UITest.Configuration.iOSAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in <1bd397951f434cd4913ddc08b7bc45af>:0 at UI.Tests.AppInitializer.StartApp (Xamarin.UITest.Platform platform) [0x00041] in <2cd1cd61003a486e92c6ffb9d58f1488>:0 at UI.Tests.TestDashboardDetailsPage.OneTimeSetUp () [0x00000] in <2cd1cd61003a486e92c6ffb9d58f1488>: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 <4fdc5ed61a074cafb49fa42deb20d521>:0 --HttpRequestException at System.Net.Http.HttpClientHandler+d__63.MoveNext () [0x004ab] in <7e581108ecb143d78ca072a020c287c3>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Net.Http.HttpClient+d__47.MoveNext () [0x000ca] in <7e581108ecb143d78ca072a020c287c3>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at Xamarin.UITest.XDB.Services.HttpService+c__async31+c__AnonStorey11+c__async10[T].MoveNext () [0x00094] in <1bd397951f434cd4913ddc08b7bc45af>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at Xamarin.UITest.XDB.Services.HttpService+c__async5.MoveNext () [0x0008b] in <1bd397951f434cd4913ddc08b7bc45af>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at Xamarin.UITest.XDB.Services.HttpService+c__async41[T].MoveNext () [0x0031b] in <1bd397951f434cd4913ddc08b7bc45af>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at Xamarin.UITest.XDB.Services.HttpService+c__async31[T].MoveNext () [0x00132] in <1bd397951f434cd4913ddc08b7bc45af>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0
at Xamarin.UITest.XDB.Services.iOSDeviceAgentService+c__async141[T].MoveNext () [0x000be] in <1bd397951f434cd4913ddc08b7bc45af>:0 --WebException at System.Net.HttpWebRequest.EndGetRequestStream (System.IAsyncResult asyncResult) [0x0003a] in :0 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <4fdc5ed61a074cafb49fa42deb20d521>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <4fdc5ed61a074cafb49fa42deb20d521>:0 at System.Net.Http.HttpClientHandler+d__63.MoveNext () [0x002e7] in <7e581108ecb143d78ca072a020c287c3>:0 --SocketException at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000b6] in :0 at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x0016d] in :0

Posts

  • stepheawstepheaw Member ✭✭
    Any update on this? I have the same issue. This is really a pain
  • daferadafera USMember ✭✭

    Hi there stepheaw,

    As far as I know, it's an XCode issue and they know it (I read that in the "Known issues" section somewhere in the XCode release notes). They don't really want to fix it or they can't....

  • daferadafera USMember ✭✭

    Also you can try to avoid that issue by using an iOS 10 version on your simulator. I think this issue only happens on iOS 11.

  • stepheawstepheaw Member ✭✭

    Thank you for the info. Have you been able to figure out a workaround? Maybe create a dummy test as the first test, and ignoring it at runtime?

  • daferadafera USMember ✭✭

    You're welcome. No, in my company we are waiting to XCode to fix it. (Meanwhile we have a server machine running the tests with an old version of XCode and UITest 2.2.2) Sorry :smile:

  • stepheawstepheaw Member ✭✭

    I found that restarting the device is able to solve this problem.
    After restarting the device, the UITests are no longer failing on the first one.
    We are able to restart the device using a library called libimobiledevice

    https://www.mankier.com/1/idevicediagnostics

    I'm running the UITests from Jenkins and in the build script before the tests are run we restart the device
    idevicediagnostics -u[deviceUDID] restart

  • daferadafera USMember ✭✭

    Hi there stepheaw. Does it work with simulators or do I have to use a real device to run the tests? I'm trying to use the id of my simulator but it just expects a 40 digit udid. Thanks in advance

Sign In or Register to comment.