MSTest throwing PlaybackFailureException when calling PlayBack.Initialize()

Locked MSTest throwing PlaybackFailureException when calling PlayBack.Initialize()

  • Tuesday, May 15, 2012 9:36 PM
     
      Has Code

    I have this method in a StartupTest class:

          [AssemblyInitialize]
            public static void OnAssemblyInitializing(TestContext context)
            {   
                Playback.Initialize();
                
                var processes = Process.GetProcessesByName("MyApplication");
                if (processes.Length == 0)
                {
                   LaunchApp(context);
                }
                else
                {
                    bool errorResuming = true;
                    try
                    {
                       
                        var authwindow = new AuthenticationWindowMap().UIOCC600OILoginWindow;
                        authwindow.Find();
                        if (!authwindow.Exists)
                        {
                            errorResuming = false;
                        }
                    }
                    catch (Exception)
                    {
                    }
    
                    if (errorResuming)
                    {
                        processes.First().Kill();
                        LaunchApp(context);
                    }
                }
            }

    It was working fine moments ago but now, I get this exception when running test from Test List Editor.

    Error Message:

    Assembly Initialization method UITests.StartupTest.OnAssemblyInitializing threw exception. Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: Cannot perform '' on the control. Additional Details: The control details were not specified. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.. Aborting test execution..

    Error Stack Trace:

    Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IRPFPlayback.SetSkipStepEventName(String skipStepEventName)
    Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.InitPlayback()
    Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize()
    Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
    Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
    Microsoft.VisualStudio.TestTools.UITesting.Playback.Initialize()
    UITests.StartupTest.OnAssemblyInitializing(TestContext context) in C:\dev\OCC600\Source - Copy\Tests\UITests\StartupTest.cs: line 38

    I have restarted Visual Studio to no avail.  Also, if I run the test by clicking on the MSTest icon besides the test method it runs fine.



    • Edited by knji Tuesday, May 15, 2012 9:41 PM
    •  

All Replies

  • Thursday, May 17, 2012 2:19 AM
    Moderator
     
     Answered

    Hi knji,

    Glad to see you again.J

    If I run the test by clicking on the MSTest icon besides the test method it runs fine.

    Would you mind sharing us more information about this issue? Where did you get the MSTest icon in VS? Do you mean that it could run well when you right click the test method in coded UI test?

    Assembly Initialization method UITests.StartupTest.OnAssemblyInitializing threw exception…Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: Cannot perform '' on the control. Additional Details: The control details were not specified. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.. Aborting test execution..

    It seems that this issue is related to your PlayBack.Initialize()in [AssemblyInitialize].

    Vishnu shared us some information in this thread:

    1. Tools Menu -> Options -> Test Execution -> Uncheck the checkbox "Keep test execution engine running between test runs"

    2. Do Playback.Cleanup() in the /AssemblyCleanupAttribute methods. See this MSN document.

    finally

                {

                    if (Playback.IsInitialized)

                    {

                        Playback.Cleanup();

                    }

                }

    3. Whether you run this app on a 64 bit machine? It seems that VS 2010 is a 32 bit application and if your tests have 64 bit assembly dependency then it will generate the similar issue. How about compiling it in x86 or Any CPU mode? Hope it could help,

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • Wednesday, May 23, 2012 2:41 AM
    Moderator
     
     

    Hi knji,

    I am writing to check the status of the issue on your side. 

    What about this problem now?

    Would you mind letting us know the result of the suggestion?

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us