Not able to launch Browser App which is already installed on device

**I am trying to launch Browser app on device using below code **
IApp app = ConfigureApp.Android.DeviceSerial("xxxxxxxx").InstalledApp("com.android.browser").EnableLocalScreenshots().StartApp();

However i am getting below error,

_Result StackTrace:
at Xamarin.UITest.Shared.Android.Commands.CommandAdbClearAppData.Execute(IProcessRunner processRunner, IAndroidSdkTools androidSdkTools)
at Xamarin.UITest.Shared.Execution.Executor.Execute[TDep1,TDep2](ICommand2 command)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.EnsureInstalled(String appPackageName, ApkFile testServerApkFile)
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at XamarinPOC.AppInitializer.StartApp(Platform platform) in AppInitializer.cs:line 26
at XamarinPOC.Tests.BeforeEachTest() in Tests.cs:line 23

Result Message: SetUp : System.Exception : Timed out waiting for result of ClearAppData2

Android test running Xamarin.UITest version: 1.3.8
Initializing Android app on device xxxxxxxx with installed app: com.android.browser
Signing apk with Xamarin keystore.
Skipping installation: Already installed._

instead of StartApp(), I used ConnectToApp() method and keprt browser app running on mobile as below
IApp app = ConfigureApp.Android.DeviceSerial("xxxxxxx").InstalledApp("com.android.browser").EnableLocalScreenshots().ConnectToApp(); app.EnterText(e => e.Id("url"), "https://en.wikipedia.org");

Then I get below error,

Result StackTrace:
at Xamarin.UITest.Utils.ErrorReporting.With(Action func, Object[] args, String memberName)
at Xamarin.UITest.Android.AndroidApp.EnterText(Func2 query, String text)
at XamarinPOC.Tests.TestBrowser() in Tests.cs:line 70
--Exception
at Xamarin.UITest.SharedApp.FirstWithLog[T](T[] results, ITokenContainer tokenContainer)
at Xamarin.UITest.Android.AndroidApp.c__AnonStorey6.<>m__0()
at Xamarin.UITest.Utils.ErrorReporting.With(Action func, Object[] args, String memberName)
Result Message:
System.Exception : Error while performing EnterText(Id("url"), "https://en.wikipedia.org")
----> System.Exception : Unable to find element. Query for Id("url") gave no results.
Result StandardOutput:
Android test running Xamarin.UITest version: 1.3.8
Initializing Android app on device xxxxxxxxx.
Exceptions while waiting for any:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:55203
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at Xamarin.UITest.Shared.Http.HttpClient.SendData(String endpoint, String method, HttpContent content, ExceptionPolicy exceptionPolicy, Nullable1 timeOut)
at Xamarin.UITest.Shared.Http.HttpClient.Post(String endpoint, String arguments, ExceptionPolicy exceptionPolicy, Nullable1 timeOut)
at Xamarin.UITest.Android.AndroidGestures.Query[T](ITokenContainer query, Object[] args, String methodName)
at Xamarin.UITest.Android.AndroidGestures.Query(AppQuery query)
at Xamarin.UITest.Android.AndroidGestures.c__AnonStorey0.<>m__0()
at Xamarin.UITest.Shared.WaitForHelper.WaitForAnyOrDefault[T](Func1 query, T[] defaultValue, Nullable1 timeout, Nullable1 retryFrequency, Nullable1 postTimeout)
Error while performing EnterText(Id("url"), "https://en.wikipedia.org")
Exception: System.Exception: Unable to find element. Query for Id("url") gave no results.
at Xamarin.UITest.SharedApp.FirstWithLog[T](T[] results, ITokenContainer tokenContainer)
at Xamarin.UITest.Android.AndroidApp.c__AnonStorey6.<>m__0()
at Xamarin.UITest.Utils.ErrorReporting.With(Action func, Object[] args, String memberName)

****how can I fix above issues?****

Answers

  • AnthonyMehallelAnthonyMehallel USMember ✭✭✭

    Hi,

    please update the framework : Xamarin.UITest (2.0.9)

    Anthony

  • sidharthgautamsidharthgautam USMember

    I am using latest version of Xamarin.UITest (2.1.4) and still facing this issue. Can anybody please help?

  • LewisKLewisK USUniversity ✭✭
    edited October 31

    You should use WaitForElement before using EnterText.

Sign In or Register to comment.