Bug 52934 - Only first test runs successfully rest get WebException
Summary: Only first test runs successfully rest get WebException
Status: RESOLVED ANSWERED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Test Cloud ()
Version: 4.2.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Kent Green [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-03-01 17:49 UTC by Adam Greene
Modified: 2017-10-28 18:13 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
UI Test Logs (37.03 KB, application/x-zip-compressed)
2017-03-01 17:49 UTC, Adam Greene
Details
Simple credit card validation (6.79 MB, application/x-zip-compressed)
2017-10-28 18:09 UTC, muzammil ahmed
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Adam Greene 2017-03-01 17:49:07 UTC
Created attachment 20063 [details]
UI Test Logs

I have 4 tests in 2 files.  If I go to the Visual Studio Test Explorer and say "Run All".  It runs the first test (random test, as each time a different may be selected as first run test) successfully.  But all subsequent tests fail with the following error:

Test Name:	WelcomeTextIsDisplayed
Test FullName:	Ditech.UITests.Tests(Android).WelcomeTextIsDisplayed
Test Source:	 : line 0
Test Outcome:	Failed
Test Duration:	0:00:51.641

Result StackTrace:	
at Xamarin.UITest.Shared.Http.HttpClient.SendData(String endpoint, String method, HttpContent content, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut)
at Xamarin.UITest.Shared.Http.HttpClient.PostUntilExpectedResultReceived(String endpoint, String arguments, String expectedContent, Int32 retries)
at Xamarin.UITest.Shared.Android.HttpApplicationStarter.Execute(String intentJson)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.LaunchApp(String appPackageName, ApkFile testServerApkFile, Int32 testServerPort)
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at Ditech.UITests.AppInitializer.StartApp(Platform platform)
at Ditech.UITests.Tests.BeforeEachTest()
--WebException
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
Result Message:	
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
  ----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.

The follow is what is reported in the Test Output Window (some text has been altered to protect the project):

------ Run test started ------
NUnit VS Adapter 2.0.0.0 executing tests is started
Loading tests from C:\dev\..\UITests.dll
Unable to create DiaSession for C:\dev\..\UITests.dll
No source location data will be available for this assembly.
Run started: C:\dev\..\UITests.dll
Full log file: C:\Users\..\log-2017-03-01_11-37-06-622.txt
Attempting IDE connection through pipe d67a257041084775bcc56bd263949fa4.
Deploying app through IDE.
Instructing the IDE to prepare the test app for execution. Session: Assembly=C:\dev\..\UITests.DLL
Platform=Android
Android test running Xamarin.UITest version: 1.3.15
Initializing Android app on device XXXXXXXXXX with installed app: com.testapp.appl
Signing apk with Xamarin keystore.
Skipping installation: Already installed.
Full log file: C:\Users\..\log-2017-03-01_11-37-59-737.txt
Attempting IDE connection through pipe d67a257041084775bcc56bd263949fa4.
Deploying app through IDE.
Instructing the IDE to prepare the test app for execution. Session: Assembly=C:\dev\..\UITests.DLL
Platform=Android
Android test running Xamarin.UITest version: 1.3.15
Initializing Android app on device XXXXXXXXXX with installed app: com.testapp.appl
Signing apk with Xamarin keystore.
Skipping installation: Already installed.
Waiting for element matching Marked("Log In").
Using element matching Marked("EmailEntry").
Using element matching Marked("EmailEntry").
Tapping coordinates [ 360, 334 ].
Attempting to dismiss keyboard
Using element matching Marked("Log In").
Tapping coordinates [ 360, 894 ].
Waiting for element matching Text("Invalid Username / Password").
Took screenshot. { Path: "C:\dev\..\screenshot-1.png", Title: "Bad Email" }
Full log file: C:\Users\..\log-2017-03-01_11-39-08-346.txt
Attempting IDE connection through pipe d67a257041084775bcc56bd263949fa4.
Deploying app through IDE.
Instructing the IDE to prepare the test app for execution. Session: Assembly=C:\dev\..\UITests.DLL
Platform=Android
Android test running Xamarin.UITest version: 1.3.15
Initializing Android app on device XXXXXXXXXX with installed app: com.testapp.appl
Signing apk with Xamarin keystore.
Skipping installation: Already installed.
Full log file: C:\Users\adam.DOVICOSBS\AppData\Local\Temp\uitest\log-2017-03-01_11-39-59-996.txt
NUnit VS Adapter 2.0.0.0 executing tests is finished
========== Run test finished: 4 run (0:02:54.5627436) ==========

Log files referenced are attached.
Comment 1 Adam Greene 2017-03-01 17:50:57 UTC
I should also mention that these same tests run perfectly on Xamarin Studio on Mac.
Comment 2 Kent Green [MSFT] 2017-06-20 18:36:03 UTC
## Potential quick fix
Sorry for the delay hearing from us. I noticed your Xamarin.UITest package version is very old. Can you try updating it to the latest stable version, and give us a status update if you're still seeing the issue? 

We generally recommend consistently running the latest stable release of Xamarin.UITest, which you can view here: https://www.nuget.org/packages/Xamarin.UITest

When you update it, make sure you are also running NUnit 2.6.4, as Xamarin.UITest is not compatible with NUnit 3 yet. I think sometimes it might still work in some local tests, but if you upload to Xamarin Test Cloud then it will always fail. (NUnit 3 support is planned however: https://testcloud.ideas.aha.io/ideas/XTA-I-124)


## Additional info to send if the above doesn't help
If you can reproduce the issue on the latest stable version of Xamarin.UITest, then some more information would be helpful to determine what's going on with this issue:

1. Send over your full version information from: 
"Help -> About Microsoft Visual Studio -> Copy Info", or 
"Xamarin Studio -> About Xamarin Studio -> Show Details -> Copy Information" (Xamarin Studio Mac)

2. What Android device or emulator are you reproducing the issue on, including Android version & model? 

3. Can you send over the sourcecode for your UITest and an APK to reproduce the issue on? If you're able to reproduce the issue using a new template app that may be sufficient if you'd prefer not to share your APK.
Comment 3 Pierce Boggan [MSFT] 2017-06-20 21:20:47 UTC
Thanks for taking the time to file this bug @Adam!

I am unable to reproduce this issue on the latest 15.3 builds. If you are still experiencing this issue, please comment on this bug with the information @Kent requested to help us diagnose and fix this issue.
Comment 4 muzammil ahmed 2017-10-28 18:09:40 UTC
Created attachment 25493 [details]
Simple credit card validation
Comment 5 muzammil ahmed 2017-10-28 18:13:27 UTC
Hi,

I am still getting the same exception ( The underlying connection was closed: The connection was closed unexpectedly.) even after updating the UITest project to 2.1.4. I am running a UItest for a simple credit card validation project. Please help, i have attached the APK file

Thanks