locked
Xamarin UI Test Android - Timed out RRS feed

  • Question

  • User48753 posted

    Hello,

    I am trying to start an application using UI Test however I am getting a System Timeout Exception. I can't figure out what is wrong. I do have the android project set to have permissions to the internet.

    Here is the code. It never makes it to the app.Repl().

     [SetUp]
            public void StartApp()
            {
                app = ConfigureApp.
                        Android.
                        ApkFile(PathtoAPK).StartApp();
                app.Repl();
            }
    
    
    Log File Entry:
    Signing apk with internal keystore.
    Exceptions while waiting: 
    System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
       at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
       at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       --- End of inner exception stack trace ---
       at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
       --- End of inner exception stack trace ---
       at System.Net.HttpWebRequest.GetResponse()
       at Xamarin.UITest.Shared.Http.HttpClient.Post(String endpoint, String arguments, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut)
       at Xamarin.UITest.Android.AndroidGestures.Query[T](AppQuery query, Object[] args, String methodName)
       at Xamarin.UITest.Android.AndroidGestures.Query(AppQuery query)
       at Xamarin.UITest.Android.AndroidApp.<.ctor>b__1()
       at Xamarin.UITest.Shared.WaitForHelper.WaitFor(Func`1 predicate, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout)
    System.Exception: Query for * failed with outcome: ERROR
    Status: 200
    Contents:
    {"reason":null,"outcome":"ERROR","detail":"java.lang.NullPointerException\n\tat sh.calaba.instrumentationbackend.query.Query.rootViews(Query.java:161)\n\tat sh.calaba.instrumentationbackend.query.Query.executeQuery(Query.java:51)\n\tat sh.calaba.instrumentationbackend.actions.HttpServer.serve(HttpServer.java:284)\n\tat sh.calaba.instrumentationbackend.actions.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:454)\n\tat java.lang.Thread.run(Thread.java:841)\n"}
       at Xamarin.UITest.Android.AndroidGestures.Query[T](AppQuery query, Object[] args, String methodName)
       at Xamarin.UITest.Android.AndroidGestures.Query(AppQuery query)
       at Xamarin.UITest.Android.AndroidApp.<.ctor>b__1()
       at Xamarin.UITest.Shared.WaitForHelper.WaitFor(Func`1 predicate, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout)
    NUnit 1.2.0.0 executing tests is finished
    ========== Run test finished: 1 run (0:01:31.0483508) ==========
    
    Thursday, November 6, 2014 4:44 PM

All replies

  • User48753 posted

    One thing I forgot to mentioned was the app will start the emulator, even though I am getting the timed out exception.

    Thursday, November 6, 2014 5:04 PM
  • User35 posted

    I always start the emulator/Android Player first.

    Friday, November 7, 2014 2:27 PM
  • User48753 posted

    Sorry I typed that last sentence wrong it will eventually start the app on the emulator even though it says it has timed out. Sorry for the confusion.

    Friday, November 7, 2014 2:38 PM
  • User99882 posted

    I'm facing the same problem. Did you find a solution Michelle?

    Monday, January 19, 2015 5:53 AM
  • User48753 posted

    Apparently it is due to slowness of the emulator. Support recommended to start with the app already started. When doing that way, app.repl() never worked. So, I moved away from using Xamarin UI Test

    Monday, January 19, 2015 2:32 PM
  • User99882 posted

    Thanks Michelle! Your answer led me to the solution! You're right, it was failing because it is taking too much time to start the App. I solved by changing the WaitTimes so it would wait longer. My emulator is very slow indeed, I can't install HAXM for other reasons. The code that I'm using to solve my problem is below, so that other people can tweak their wait times:

    public static AndroidApp StartLocalAndroid() { return Xamarin.UITest.ConfigureApp.Android .ApkFile(PathToApk) //.ApiKey("zzzz") .Debug() .WaitTimes(new WaitTimes()) .StartApp(); }

    public class WaitTimes : IWaitTimes { public TimeSpan GestureWaitTimeout { get { return TimeSpan.FromMinutes(1); } } public TimeSpan WaitForTimeout { get { return TimeSpan.FromMinutes(1); } } }

    Monday, January 19, 2015 11:29 PM
  • User271436 posted

    Even after adding the WaitTimes also i am facing same problem , i am using Xcode 8.1 and iOS 10.1 vewrsion. Here is my code ....

    Testcase.cs

    public void BeforeEachTest() { app = ConfigureApp.Android .EnableLocalScreenshots() .PreferIdeSettings() .DeviceIp(TestConfigDroid.DeviceId) .InstalledApp(TestConfigDroid.AndroidBundlId) .WaitTimes(new WaitTimes()) .StartApp(); }

    WaitTime.cs

    public class WaitTimes : IWaitTimes { public TimeSpan GestureWaitTimeout { get { return TimeSpan.FromMinutes(1); } } public TimeSpan WaitForTimeout { get { return TimeSpan.FromMinutes(1); } } }

    Tuesday, November 8, 2016 5:40 AM
  • User170482 posted

    excellent Alex Botelho, your post solved my issues. thanku very much

    Tuesday, April 4, 2017 1:24 PM