HP QTP 11: Script execution fails when running in Firefox, but Debug Viewer shows result of operation

浪尽此生 提交于 2019-12-06 00:41:34
vmg

I found the reason and found workaround.

So, somewhere in associated library I has a code:

Set itemCol = windows.item(i) ' line 1
sClassName = itemCol.className ' line 2

And in another library I have an expression :

arrMyTradeInfo=GlobalDictionary.Item("gdTrades")

With this code during execution of line 1 QTP will give error:

TypeError: obj[FuncName] is undefined But if I change code to (notice "item" function name - it in lower-case now) - the line 1 will work!!!:

arrMyTradeInfo=GlobalDictionary.item("gdTrades")

But then it will not work in line 2 - see update 3 in the question itself - the value of sClassName will be empty, but itemCol.className could contain string. In another library I have a function (notice className parameter):

Function GetFirstObjectByClassName(byVal Parent, byVal className, byVal tag)
    Dim result
     result = getElementsByClassName(Parent, className, tag)
     If (UBound(result)<0) Then
        set GetFirstObjectByClassName = Nothing
    Else
        set GetFirstObjectByClassName = result (0)
    End If   
End Function

When I changed it name to something different (csName for example), line 2 is working!!!

Function GetFirstObjectByClassName(byVal Parent, byVal csName, byVal tag)
    Dim result
     result = getElementsByClassName(Parent ,csName, tag)
     If (UBound(result)<0) Then
        set GetFirstObjectByClassName = Nothing
    Else
        set GetFirstObjectByClassName = result (0)
    End If   
End Function

So, this is workaround. I can't explain it why is this happening, my guess is: VBScript is not strictly-typed. And in QTP they implemented something like "virtual functions calls" like in C++ and Java based on some kind of run-time type information, butfor DOM objects from Firefox there was some collision, they gathered RTTI in wrong way.

So, the main conclusion and concern: only one wrong letter-case (Item instead of item) could broke your code, that work with firefox's dom and will give you many pleasant hours of debugging! SO, be careful!

Will open ticket with HP support.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!