I found strange behavior in QTP 11 today: expression
Browser().Page().WebElement("PositionManagerContainer").WebElement("LoadingMessage").Object.ParentNode.ParentNode
Gives error: Object Required “.Object.ParentNode”
But expression
Browser().Page().WebElement("PositionManagerContainer").WebElement("LoadingMessage").Object.parentNode.ParentNode
(the difference in case of ParentNode member of .Object)
Is correct and works fine without any errors.
Browser is Firefox. In IE it worked fine.
Can someone explain why it happens? Just for interest.
This is a very good (and subtle) point.
In general
.Objectallows access to the native object in the application being tested. Since QTP is VBScript based this means that the.Objectproperty of test objects isIDispatch.When working with IE QTP can pass the MSHTML object that IE exposes (and which supports
IDispatch), since MSHTML is designed to work with VBScript these objects are case insensitive. However when working with Firefox there is noIDispatchsupporting object which is exposed by the browser. Therefore QTP has to create a proxy object that implementsIDispatchby querying the object exposed by Firefox. Since Firefox is designed to work with JavaScript (which is case sensitive) this proxy object is automatically case sensitive.The error you saw came from the fact that the first
ParentNodereturnedEmptyso the second.ParentNodethrew an error.Therefore when using
.Objectwith Firefox you must use the correct casing for the properties and methods you access.