Forum Xamarin Xamarin Test Cloud (Read Only)

Xamarin.UITest backdoor calling IApp.Invoke method with parameter throws Exception

Hi everyone,

I'm trying to set the start page of my UI tests using backdoor. I have created a public method with export tag in my Android MainActivity and as long as this method is a simple method without any parameter, the Invoke is working perfectly. But I need to pass a parameter to my method to determine which page should be set as MainPage. So, when I modify my Android method to the following:

[Export("SetMainPage")]
public void SetMainPage(string arg)
{
...
}

and calling this line in my UI Test:

this.app.Invoke("SetMainPage", "LoginView");

I'm getting the following error:

System.Exception : Error while performing Invoke("SetMainPage", "LoginView") ----> System.Net.Http.HttpRequestException : Fehler beim Senden der Anforderung. ----> System.Net.WebException : Die zugrunde liegende Verbindung wurde geschlossen: Die Verbindung wurde unerwartet getrennt.. bei Xamarin.UITest.Utils.ErrorReporting.With[T](Func`1 func, Object[] args, String memberName) bei Xamarin.UITest.Android.AndroidApp.Invoke(String methodName, Object argument) bei UITest.OnboardingTest.WelcomeScreenShowsUp() in D:\Projekte\Sonstige\UEBE\UEBE_CycloTestApp\code\V2\UITest\OnboardingTest.cs:Zeile 79. --HttpRequestException bei Xamarin.UITest.Shared.Http.HttpClient.SendData(String endpoint, String method, HttpContent content, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) bei Xamarin.UITest.Shared.Http.HttpClient.Post(String endpoint, String arguments, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut) bei Xamarin.UITest.Android.AndroidGestures.Invoke(String methodName, Object[] arguments) bei Xamarin.UITest.Utils.ErrorReporting.With[T](Func`1 func, Object[] args, String memberName) --WebException bei System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) bei System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

I've tried several things, but nothing has worked so far. Internet permissions are assigned and I'm using the newest version of Xamarin.UITest. Does anyone have any idea, what is going wrong here?

Thanks

Answers

  • deb_b_deb_b_ USMember

    If anyone facing the same problem, I've solved it for my code by using Java types, e.g. using Java.Lang.String instead of string. That will also work when you try to pass a more complex object using JsonConvert (make sure to use the latest version of it).

Sign In or Register to comment.