4个关联library的方法

1) By using ‘File > Settings > Resources > Associate Function Library’ option in QTP.
2) By using Automation Object Model (AOM).
3) By using ExecuteFile method.
4) using LoadFunctionLibrary method.

ExecuteFile是最慢而且有时候不稳定,基本可以用LoadFunctionLibrary来代替.

第二种方法在编写框架的时候非常有用,比如我的框架就使使用如下代码关联一个用户指定文件夹下的所有library,动态又高效.

If TAFQTPLibraryPath <> "" Then
                Dim TAFCoreLibraries() As String = Directory.GetFiles(TAFQTPLibraryPath)
                For Each CoreLib As String In TAFCoreLibraries
                    If CoreLib.EndsWith(".vbs") Then
                        qtApp.Test.Settings.Resources.Libraries.Add(CoreLib)
                    End If
                Next
End If

你可能感兴趣的:(QTP Library)