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 Fir开发者_开发知识库efox. In IE it worked fine.
Can someone explain why it happens? Just for interest.
This is a very good (and subtle) point.
In general .Object
allows access to the native object in the application being tested. Since QTP is VBScript based this means that the .Object
property of test objects is IDispatch
.
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 no IDispatch
supporting object which is exposed by the browser. Therefore QTP has to create a proxy object that implements IDispatch
by 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 ParentNode
returned Empty
so the second .ParentNode
threw an error.
Therefore when using .Object
with Firefox you must use the correct casing for the properties and methods you access.
精彩评论