QTP对象的一些隐藏的属性和方法

本文深入挖掘QTP测试对象中的未公开方法和策略,通过使用PDM.DLL,作者探索了每个测试对象,并分享了在常规智能提示自动完成中未展示的有趣发现。内容包括所有对象共有的五种方法,如高亮、查询值、获取与设置属性、转字符串、初始化等,以及针对不同环境的具体方法解析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I’ve been doing some digging into QTP’s test-objects, hoping to find some undocumented methods and techniques. Armed with the power of PDM.DLL, I’ve explored each test object, and have come up with these interesting results, all of which don’t show up on your regular intellisense autocomplete.

As this is still a work in process, the function of many methods is still unclear. I’ve set up a color coding system to make things more clear – Red = Don’t have a clue. Black = Have a pretty good idea / an educated guess. Green = Presumably know exactly what the method is supposed to do.

If any of you know the purpose and function of these methods, please fill me in by dropping a comment, and I’ll update the article.

Update: mayno224 has informed us that a Java object MethodWizard method will open a window with all the object’s internal methods (similar to the .Net form’s spy).

All Objects

All QTP test objects have these five methods in common:

1. Highlight – Highlights the object, much like the highlight feature in the object-repository.

2. QueryValue(Property, PropertyData), GetProperty(Property, pFlags, pType, pParameterName) and SetProperty(Property, Value, pFlags, pType, pParameterName)– I haven’t been able to figure out what these method do. If any of you manage to crack this up, I would appreciate it if you dropped a comment.

3. ToString – Returns a string representation of the object. Usually it’s just the name.

4. Init – As described here, re-links the test-object to the runtime object. Especially useful in a web environment, after a page refresh.

Web

All Objects:

Method

Description

.MakeObjVisible Scrolls the object into view (if needed). Similar to the documented .MakeVisible method for ActiveX objects

Browser:

Method

Description

.AddCookie(Domain, Cookies)
.GetCookies(Url, Cookies)
Probably syntactically sets / gets cookie data.
.RefreshWebSupport Perhaps the underlying method behind the visible .Refresh method?
.SubmitForm(bstrUrl, bstrTargetFrame, bstrPostData, bstrHeaders) Submit forms “hardcore” style.

Page:

Method

Description

.RefreshObjects Probably performs .Init on all its childobjects.
.StartTransaction(Name)
.EndTransaction(Name, Status)
.SetTransactionStatus(Status)
Don’t have a clue.
.SaveLayout(pDoc)
.RestoreLayout(elemTag, elemID, propName, propValue)
Presumably saves/restores the visible layout of the page.

All other web objects (WebElement, WebList, WebButton, etc.):

Method

Description

.Submit Presumably submits a form, if activated on the relevant object
.MouseOver Similar to firing the OnMouseOver event.

Standard Windows

All Objects:

Method

Description

ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly, BUTTON, DoubleClick) Extremely useful method! A merge between .GetTextLocation and .Click: It finds the specified text within the object, and clicksAll the parameters are self-explanatory. BUTTON is the button code (look under the click method in QTP help); and DoubleClick is boolean.

WinEdit:

Method

Description

.SetText Seems to be exactly like the regular .Set method. However, Neither function uses the other (checked with RegisterUserFunc)

WinButton:

Method

Description

.Press Seems to be exactly like the regular .Click method. However, Neither function uses the other (checked with RegisterUserFunc)

WinMenu:

Method

Description

.PrepareMenu(phSubMenu, peMenuObjectType) Perhaps has something to do with loading the sub-menu items for a given menu option.

.Net (SWF objects)

All Objects:

Method

Description

ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly, BUTTON, DoubleClick) Same as in Standard Windows.
Spy Launches the .Net form spy for the relevant object. Perfect for objects you cannot get your mouse to point to.
CreateManagedObject(bsType, bsFile, pVal) Have no idea.

SwfTable:

Method

Description

GetCellCoord(Row, Column, X, Y) Probably the underlying method behind ClickCell. Should return the cell coordinates though the ByRef X,Y variables, but keeps spitting out an error (Perhaps the variables have to be cased into long integers?).

SwfButton:

Method

Description

.Press Seems to be exactly like the regular .Click method. However, Neither function uses the other (checked with RegisterUserFuc)

.Java

All Objects:

Method

Description

InvokeMethod(MethodName, MethodArguments) My guess is it calls an inner method of the object.
MethodWizard() Thanks to Mayno224: Will present a screen with all the object’s internal methods. Kinda similar to .Net objects Spy.
RequestFocus() Presumably brings the object into focus.
ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly, BUTTON, DoubleClick) Same as in Standard Windows.

Other environments and updates will be published when I’ve completed my investigation, and when reads will drop in more information through comments.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值