1

I'm trying to run UITest locally for an iOS app written in Xamarin.Forms, but I'm keep getting this error:

SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to contact DeviceAgent
  ----> System.AggregateException : One or more errors occurred.
  ----> Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to contact DeviceAgent on 127.0.0.1
  ----> System.Net.Http.HttpRequestException : An error occurred while sending the request
  ----> System.Net.WebException : Error: ConnectFailure (Connection refused)
  ----> System.Net.Sockets.SocketException : Connection refused

This happens on all simulator I've tested (and on a real device it never worked).

Both the iOS app itself and the test code are under the same solution, so the app project is included as part of the test project. I did managed to run at the past, but it seems to stopp working. I'm not sure since when, but I think since I copied to solution files to a different location. However, even in the new location, I've managed to debug the test a few times (so I don't believe that the location of the solution is the issue). One time it worked by changing the debugging portof the Xamarin.iOS project (but that trick doesn't seem to work anymore), and other times are mainly "voodoo" ("start debugging the test >> open the app >> close it >> open the DeviceAgent on device >> close it >> wait for a minute" seems to work best, but still hardly ever).

The DeviceAgent is installed on all of the simulators, but it does not starts, only after the test fails (and then it starts and do nothing).

The iOS app is using the Xamarin.TestCloud.Agent version 0.21.4, and the tests project is using the Xamarin.UITest version 2.2.3.

I've tried looking for the answer here but only found this, which doesn't seem to help.

What can be the issue?

yanivca
  • 23
  • 4

1 Answers1

0

I found that when this happened debugging my Xamarin.TestUI tests I had to manually go to the simulator app and select to "Device->Erase All content and settings" from the simulator menu before debugging the test again.

Resetting the simulator in code at the start of my UI tests seemingly did not solve this problem when debugging. It had to be reset manually.

Tim Hobbs
  • 269
  • 2
  • 4