Open a Test with Associated Add-ins Loaded

In this post i am going to describe how to automatically load all addin that are associated with test only.The code will open the test at run time and opens associated addins.
*******************************************************
'Description:
'
'This example opens a test and loads all the add-ins associated with the test.
'
'*******************************************************

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim blnNeedChangeAddins ' Declare a flag for indicating whether the test's 

                        'associated add-ins are currently loaded
Dim arrTestAddins ' Declare the variable for storing the test's associated add-ins

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object



' Create an array containing the list of addins associated with this test
'Change Location as per your test
arrTestAddins = qtApp.GetAssociatedAddinsForTest("C:\Tests\Test1")

' Check if all required add-ins are all already loaded
blnNeedChangeAddins = False ' Assume no change is necessary
For Each testAddin In arrTestAddins ' Iterate over the test's associated 

                                    ' add-ins list
    If qtApp.Addins(testAddin).Status <> "Active" Then ' If an associated add-in is 

                                                        ' not loaded
        blnNeedChangeAddins = True ' Indicate that a change in the loaded add-ins 

                                   'is necessary
        Exit For ' Exit the loop
    End If
Next

If qtApp.Launched And blnNeedChangeAddins Then
        qtApp.Quit ' If a change is necessary, exit QuickTest to 

                   '  modify the loaded add-ins
End If

If blnNeedChangeAddins Then
    Dim blnActivateOK



   
'Load the add-ins associated with the test and check whether they load successfully.
    blnActivateOK = qtApp.SetActiveAddins(arrTestAddins, errorDescription)
    If Not blnActivateOK Then ' If a problem occurs while loading the add-ins
        MsgBox errorDescription ' Show a message containing the error
    WScript.Quit ' And end the automation program.
    End If
End If

If Not qtApp.Launched Then ' If QuickTest is not yet open
    qtApp.Launch ' Start QuickTest (with the correct add-ins loaded)
End If
qtApp.Visible = True ' Make the QuickTest application visible

qtApp.Open "C:\Tests\Test1" ' Open the test
Set qtApp = Nothing ' Release the Application object

Comments