1. Using QTP version 9.2
2. Including a single lib on the Test Settings... Resource tab
3. Inclusion syntax is path relative: "..\globalLib.vbs"


Today I added one shared vbScript library, noted above, to a small evaluation test case. Most of time I can run my test case and get no complaints from QTP about the library. Many of the libs functions are being succesfully called and used.

But three times today (perhaps out of 30 or 40 test invocations), QTP starts and then terminates almost immediately with a Run Error dialog that states:

"Type mismatch: '0'

QTP then "opens" the library as read-only on its own tab and claims that the library contains a single line of code, actually a single character, zero, 0.

At that point I confirm with a text editor that the lib file contains its 300 lines of code, none of which is corrupted. Dismissing the dialog and tab displaying the erroneous file and restarting won't clear up the problem. I either have to restart QTP or, open the lib as writable in QTP (which still says it only contains a 0) and then cut the real contents from the text editor and paste it into the lib file open by QTP, then write it out.

Has anyone encountered this problem, and perhaps received a fix from Mercury? I will probably waste 10 of hours reporting this, if no one else has reported this bug.

-Thanks, Terry

P.S. Actually I have looked at the char it is complaining about and it is a capital 'O', not a zero digit. And the first line in my lib is:

Option Explicit

So it appears QTP is reading the file and then barfing after the first char. This is definitely a weird problem.

PS2 It gets better. When I comment out the Option Explicit statement, QTP then claims the file contains a single ' char.

PS3 Well, I have found "my" problem.

Having worked for months with QTP 8.2 that had not library editor capability I have grown use to editing my the libs I include in QTP with an external editor (TextPad in my case). I continued to do this today, when including the above lib in my test script. Now I find I get the error/failure (tough to call this a QTP "bug") described above consistently if I edit and then save the lib with the external editor--the next time QTP runs it produces the problem described above.

So the problem's solution is: "if you have QTP running, and it includes libX.vbs, only use QTP to edit/change libX.vbs and not an external editor". (This situation could certainly be handled better by QTP--for example TextPad notices that "someone else", QTP in this case, has altered the file and asks "do you want to reload it"?)