none
Why Coded Ui execution is very slow RRS feed

All replies

  • Hi SrikarReddy,

    Welcome to MSDN forum.

    After research, I found an appropriate answer to boost execution time, please refer the below code from the answer:

    [CodedUITest]
    public class CodedUITest1
    {
        [TestInitialize]
        public void TestInit()
        {
            // Call a common routine to set up the test
            MyCodedUITests.StartTest();
        }
    
        [TestMethod]
        public void CodedUITestMethod1()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            this.UIMap.RecordedMethod1();
        }
    }
    
    class MyCodedUITests
    {
        /// <summary> Test startup. </summary>
        public static void StartTest()
        {
            // Configure the playback engine
    
            Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.Disabled;  //allows the test to run at full speed. 
            Playback.PlaybackSettings.MaximumRetryCount = 10;  //wair for loading page then response
            Playback.PlaybackSettings.ShouldSearchFailFast = false;  //set full timeout to load page
            Playback.PlaybackSettings.DelayBetweenActions = 500;  //the delay time between the UI actions
            Playback.PlaybackSettings.SearchTimeout = 1000;  //the dafault is 3min
    
            // Add the error handler
            Playback.PlaybackError -= Playback_PlaybackError; // Remove the handler if it's already added
            Playback.PlaybackError += Playback_PlaybackError; // Ta dah...
        }
    
        /// <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;
        }
    }
    

    After the experiment in my side, the execution time is reduced.

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, May 14, 2019 9:37 AM