Very strange symptom:
Create a test with the following content and no associated libraries:
Print IsEmpty (Browser("index:=0"))
The point is to call IsEmpty
with any test object.
Result when executed: The obvious (and expected), it prints: "false
" (provides you have at least one window open on your desktop).
Run result looks fine in the viewer, like this:
Now create a function library with the following content:
Option Explicit
Public Function MyFunc(Object, MethodName, Arguments, RetVal)
Print "Welcome."
End Function
Do not associate this library with the test.
Create a recovery scenario with the following properties:
Trigger: Test run error
Error: Any error
Recovery operation: Function call
Library: The one you just created
Function to call: MyFunc
Post-Recovery Test Run Options:
Process to next action or component iteration
Associate the recovery scenario to the test you created in the beginning. Set "Activate Recovery scenarios:
" to "On error
".
Run the test. The output is as expected, but the run result looks like this:
The "Error" node has the following details ("Element nicht gefunden" is german and means "Element not found", I am very surprised to see a localized error message here):
How´s that? It appears that IsEmpty
generates such an entry whenever it is called with a test object.
Could it be this is a bug?
My current workaround is to introduce my own IsEmpty
function which disables the recovery scenario, calls the original IsEmpty
function, and re-enables the recovery scenario.
Which is a horror, because the IsEmpty
replacement cannot be named IsEmpty
. That would result in a recursive call, because I cannot call the original version from the replacement if it has the same name (or can I?). And calling something different when you want to call IsEmpty
is easily forgotten.
I cannot live with the warnings generated for every IsEmpty
call if a recovery scenario is active.
What´s going on?
Can you guys reproduce this?
Is there a better workaround?
English (of course) QTP 11.00 build 1018 with .net, ActiveX, Delphi, Java, Oracle, Silverlight, Web, Web Services and WPF add-ins, but none of them active for this demo. Using Hotfixes QTPWEB_00078 and QTPJV_00044. Windows 7.
Update: I just figured I can check for VarType (Obj) = vbEmpty
, so I can create an IsEmpty
replacement as outlined, but named IsEmpty
. I.e. I have a workaround, but still am wondering if this is a QTP bug.
Update 2: The VarType (Obj) reference does not work, it generates the same strange run result warning.
Update 3: It seems IsEmpty cannot be replaced by a function with the same name. It The intrinsic function is always called.
Update 4: The closest one can come to replacing an intrinsic is the method outlined in http://www.knowledgeinbox.com/articles/qtp/advanced-qtp/overriding-default-functions-using-function-pointers/, but it requires a declaration and an assignment in every action script. Sigh.