Instruct UFT to Capture Movie Segments of Each Error and Warning
Source code
'************************************************************************************************************************
'Description:
'
'This example opens UFT, configures UFT to record movies of tests with errors or warnings using
'options to minimize the file size, and then runs a test.
'
'Assumptions:
'-There is no unsaved test currently open in UFT. For more information,
'see the example for the Test.SaveAs method.
'-When UFT opens, it loads the add-ins required for the test. For more information,
'see the example for the Test.GetAssociatedAddins method.
'************************************************************************************************************************

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Dim qtMovieOpts 'As QuickTest.ScreenRecorderOptions ' Declare a Run Results Options object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start UFT
qtApp.Visible = True ' Make the UFT application visible

' Set UFT movie options
qtApp.Options.Run.MovieCaptureForTestResults = "OnWarning" 'Set UFT to capture movie segments of each error and warning
qtApp.Options.Run.SaveMovieOfEntireRun = "FALSE" 'Save only the movie segements that lead up to an error or warning
qtApp.Options.Run.MovieSegmentSize = "4000" 'Set each movie segment to be a maximum of 4MB.

Set qtMovieOpts = qtApp.Options.Run.ScreenRecorder ' Create a Screen Recorder Options object

'Set movie recording preferences to minimize the movie file size
qtMovieOpts.DeactivateShowWindowContents = True
qtMovieOpts.RecordSound = False
qtMovieOpts.SetPlainWallpaper = True

qtApp.Open "C:\Tests\Test1", True ' Open a test in read-only mode

' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "oneIteration" ' Run one iteration of the test
qtTest.Settings.Run.OnError = "NextStep" ' Instruct UFT to perform next step when an error occurs

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location

qtTest.Run qtResultsOpt ' Run the test and record a movie of the run.

qtTest.Close ' Close the test

Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object