Launch UFT with the proper Add-Ins

Hello friends.

I would like to hear your "best-practice" apprroach regarding this...
I have various applications under testing process. Java, Oracle, WPF, Web, etc...

I do not wish to launch UFT with all of these addins loaded. It is not correct to do.
What I wish to create is a mechanism, that will decide what to do according to what's happening now. See what addins are loaded, see what is required for the test and decide what to do..!!
I need to hear what is your idea regarding this. Since UFT cannot load addins in runtime, I need to create something that will launch UFT with only the correct addins...:
I call this function from my test:

ret_addins = Verify_AddIns(Environment("TestDir"), missing_addins)
If (ret_addins = -1) Then
    msgbox "The following add-ins are missing :" &vbcrlf& missing_addins, 16"Missing Addins"
    ExitAction -1
End If

Function Verify_AddIns(test_name, missing_resources)
    
    Set qtApp = CreateObject("quicktest.application")
    
    ' Create an array containing the list of addins associated with this test
    arrTestAddins = qtApp.GetAssociatedAddinsForTest(test_name) 
    ' Check if all required add-ins are all already loaded
    blnNeedChangeAddins = False ' Assume no change is necessary
    missing_addins = ""
    For Each testAddin In arrTestAddins ' Iterate over the test's associated add-ins list
        addin_status = qtApp.Addins(testAddin).Status
        If (addin_status <> "Active") Then ' If an associated add-in is not loaded
            print("The Add-In : " & testAddin & " is NOT LOADED with UFT. Test will now abort !")
            blnNeedChangeAddins = True ' Indicate that a change in the loaded add-ins is necessary
            missing_addins = missing_addins & testAddin & " " 
        End If
    Next
    
    ' Exit condition if add-ins need to be changed.
    If (blnNeedChangeAddins) then
        print("Missing add-ins in UFT : " & missing_addins)
        Reporter.ReportHtmlEvent micFail, "Missing Add-Ins in UFT""These Add-Ins were not loaded with UFT : " & missing_addins
        Verify_AddIns = -1    
        missing_resources = missing_addins
        Exit Function
    End If
    
    Verify_AddIns = 0
    
End Function

So far goes for the decision point.
Now, how would you suggest I do for the modification of the add-ins...?

This is the command that can load the add-ins however this could be done before UFT starts.
ret_load_addins = qt_app.SetActiveAddins(arrTestAddins, err_desc)

So what is your suggestion on this topic..??

  • Are you aware of the UFT AOM addin capability?

    '************************************************************************************************************************
    'Description:
    '
    'This example opens a test and loads all the add-ins associated with the test.
    '
    'Assumptions:
    'There is no unsaved test currently open in UFT.
    'For more information, see the example for the Test.SaveAs method.
    '************************************************************************************************************************
    
    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
    
    arrTestAddins = qtApp.GetAssociatedAddinsForTest("C:\Tests\Test1") ' Create an array containing the list of addins associated with this test
    
    ' 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 UFT to modify the loaded add-ins
    End If
    
    If blnNeedChangeAddins Then
        Dim blnActivateOK
        blnActivateOK = qtApp.SetActiveAddins(arrTestAddins, errorDescription) ' Load the add-ins associated with the test and check whether they load successfully.
        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 UFT is not yet open
        qtApp.Launch ' Start UFT (with the correct add-ins loaded)
    End If
    qtApp.Visible = True ' Make the UFT application visible
    
    qtApp.Open "C:\Tests\Test1" ' Open the test
    Set qtApp = Nothing ' Release the Application object

    Mark Smith.

     

  • Hi,
    Not sure I have heard of AOM AddIn but know of the concept of AOM.

    I know that piece of code from the web, however I beleive it aims more to be run through the file sytem as a VBS for example.

    What I was asking is what is your suggestion regarding how to run this from UFT itself...? 

  • Sorry Liorde, I run my scripts via Jenkins and use the VBS drivers, I thought most did this.

    One thing to note - You are using the AOM from within UFT using Set qtApp = CreateObject("quicktest.application")

    This is not recommended as you are driving UFT via its API from within UFT isself, sort of like a circular reference.

    Mark Smith.

  • Yes I know... we're a bit "behind" here...(not so tech savy)

    So what would you suggest...? I can launch UFT and make it check all it has to check as for the Add Ins. And if a change IS needed, would you recommend that UFT creates a VBS file? This I can do, however who would run this VBS file that would re-launch UFT??

    What do you think ??