Forum Discussion
HKosova
Alumni
14 years agoHi Anagramma,
Testing the availability of the Log object from VBScript is nontrivial, because it has the same name as VBScript's built-in Log function. So, the Log identifier is always defined in VBScript; it just has another meaning depending on the context.
The code you posted shows an error, because when TestComplete's Log object is unavailable, Log is treated as a function call and, therefore, requires parameters, e.g: Log(100).
To avoid the error, you can use the following code instead to perform the check:
When the Log object is unavailable, you can display error messages using the aqDlg object methods such as aqDlg.ShowError. For example:
Hope this helps!
Testing the availability of the Log object from VBScript is nontrivial, because it has the same name as VBScript's built-in Log function. So, the Log identifier is always defined in VBScript; it just has another meaning depending on the context.
The code you posted shows an error, because when TestComplete's Log object is unavailable, Log is treated as a function call and, therefore, requires parameters, e.g: Log(100).
To avoid the error, you can use the following code instead to perform the check:
Function IsLogObjectAvailable
On Error Resume Next
Dim i : i = Log(100)
If Err.Number <> 0 Then
IsLogObjectAvailable = True
Err.Clear
Else
IsLogObjectAvailable = False
End If
End Function
When the Log object is unavailable, you can display error messages using the aqDlg object methods such as aqDlg.ShowError. For example:
If IsLogObjectAvailable Then
Log.Error "error"
Else
aqDlg.ShowError "error"
End If
Hope this helps!