28374

Coded ui Test fails at random times on server

Question:

I am fairly new to the testing environment but I am stuck with a problem.

i have created a test case (a few tests combined in an ordered test) and when I run them on my own pc they always pass (tried it many times to be sure) but when I run the test on our server the test fails at random times. examples - he doesn't right click a list to get the context menu - he seems to forget to click on a button so he cant access the next window. etc if i run the test again he may go over the previous fail but fails on something else.

so far. out of +- 30 times i have run he test i had 5 success runs. and this should be a base test so there should be no bug or known problem. i have the feeling that the server needs more time to complete the test. so i did research and already added many playbacksettings and a Playback_PlaybackError. test case made in Visual studio 2013 part with recording part written code. build in visual studio and server tested with microsoft test manager 2013, win8 envir

is there anything i do wrong? or is there something wrong with the server configuration?

Thanks in advance.

so far I tried some of these (and repeat in every testmethod)

public CodedUITest1() { Playback.PlaybackSettings.MatchExactHierarchy = true; Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.Control; Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.TopLevelWindow; Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None; Playback.PlaybackSettings.SearchTimeout = 2000; Playback.PlaybackSettings.ShouldSearchFailFast = true; Playback.PlaybackSettings.ThinkTimeMultiplier = 2; Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads; Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly; Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.Disabled; Playback.PlaybackSettings.WaitForReadyTimeout = 2000; Playback.PlaybackError -= Playback_PlaybackError; Playback.PlaybackError += Playback_PlaybackError; } /// <summary> PlaybackError event handler. </summary> private static void Playback_PlaybackError(object sender, PlaybackErrorEventArgs e) { // Wait a second System.Threading.Thread.Sleep(1000); // Retry the failed test operation e.Result = PlaybackErrorOptions.Retry; }

Answer1:

Try to use

yourcontrol.WaitForControlReady()

function as well before performing any action on control. This function will stop the thread till your control becomes ready for accepting any action.

Answer2:

Seems the problem was server based. I added a global delaybetweenactions and the test seems to run very smooth. Problem fixed

Answer3:

I had the similar problem with a set of 20 odd Coded UI Tests in my project, which used to randomly fail on the server, but always ran fine locally. We looked out for a number of troubleshooting techniques to overcome this mysterious 'random' factor. The biggest problem while analyzing these test failures is that the error stack trace might indicate the line of code which might be completely unrelated to the actual cause of failure.

We figured out that we can enable HTML logging in our Coded UI tests. This is very easy and can either be enabled for individual tests or for all the tests in the project. Just add the below code to your app.config file

<a href="https://i.stack.imgur.com/dVzzo.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/dVzzo.png" data-original="https://i.stack.imgur.com/dVzzo.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Once you have the tracing enabled, the tests will display step by step details of how Coded UI tried to execute the tests - with screenshots of your application. This is very beneficial in troubleshooting the actual cause of test failures.

Recommend

  • Xamarin Forms: Letter spacing in Label Text
  • Can't eliminate Access corruption
  • Microsoft Pubcenter Ads In WPF Application
  • Why do I get this error 'binding to target method' using Delegate.CreateDelegate?
  • FSharp.Data Csv.Load() failed with Only web locations are supported
  • $.ajax & passing data to .asmx webservice
  • PHP file_exists() anomaly
  • How Does Navigation in xamarin.forms Works?
  • How could I prohibit anonymous access to my NodeRed UI Dashboard on IBM Cloud(Bluemix)?
  • call a java program from a webapp in tomcat server - the java program is out side of tomcat server
  • It is possible use the same sql azure instance from two different cloud service of two different sub
  • Microsoft Excel Pivot miscalculation in Sum for positive and negative numbers
  • Retaining data after updating application
  • C# List of Panels
  • Creating PDF from TIFF image using iText
  • How to get data from **Realm database** using **date object**?
  • Hide HTML elements without javascript, only CSS
  • How to access culture data in globalize.js V1.0.0
  • List images(01.png) and descriptions(01.txt) from directory
  • Is it possible to open regedit and navigate to straight to a specific key using process.start?
  • Spring Cloud Microservice Architecture Confusion
  • how to avoid repetitive constructor in children
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Saving Changes After In-App Purchase Has Been Purchased
  • Meteor: Do Something On Email Verification Confirmation
  • How to install a .deb file on a jailbroken iphone programmatically?
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • How can I send an e-mail from a vbs script
  • Where to put my custom functions in Wordpress?
  • R: gsub and capture
  • RestKit - RKRequestDelegate does not exist
  • Is there a mandatory requirement to switch app.yaml?
  • WPF Applying a trigger on binding failure
  • Benchmarking RAM performance - UWP and C#
  • JTable with a ScrollPane misbehaving
  • unknown Exception android
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Net Present Value in Excel for Grouped Recurring CF
  • How can I use threading to 'tick' a timer to be accessed by other threads?