qtp为什么不能将标示属性复制到防火墙设备应该粘贴明确标示,表明板

QTP专家视图方法总结
专家视图,也叫脚本视图,属于中比较高级的功能选项。在该视图中,人员可以直接修改测试脚本(VB脚本)的代码,来增强测试脚本的功能,它要求测试人员具有一定VB脚本语法基础。
当然,测试脚本中也不完全是VB脚本,严格意义上来说,QTP的测试脚本应该是标准 VB脚本和QTP测试对象的组合体。
所谓的QTP测试对象,就是QuickTest定义的用来表示Windows窗体元素的对象,如同窗口,命令按钮等,每一个QTP测试对象都有若干个方法和属性,允许用户加以修改。
就是我们刚才录制的测试脚本的专家视图:
我们直接在该视图中修改和在关键字视图中修改的效果是一样的。
VB脚本是一种容易并且功能强大的脚本,它是VB的一个子集,遵循VB的语法。
如果读者原来没有接触过VB脚本的话,可以将关键字视图和专家视图中的对应项结合起来学习。
下面简单介绍一下其语法:
常见的对象名:
Dialog对话框,括号里面的参数表示对话框标题栏上的名字
WinEdit:Windows窗体中的文本框
WinButton: Windows窗体中的命令按钮
ActiveX: ActiveX控件
WinComboBox: Windows窗体中列表框
常见的事件名:
Set:当在文本框中输入信息时会触发该事件
Click:当点击命令按钮时会触发该事件
Select:当选择列表框或是单选按钮时会触发该事件
Close:当关闭一个标准窗口或对话框时会触发该事件
下面在为大家介绍一下QTP中VB脚本中的一些通用语法规则,供大家参考:
比如下面两个例子:
Dim passengers
passengers =
Browser(&MercuryTours&).Page(&Find Flights&).WebEdit(&numpassengers&).GetROProperty(&value&)
上面的例子定义了一个名为passengers的变量名
Set UserEditBox =
Browser(& Tours&).Page(&Mercury Tours&).WebEdit(&username&)
UserEditBox.Set &John&
在上面的例子中,首先通过Set方法将“Mercury Tours”网页上的“username”文本框对象赋给了UserEditBox变量,然后再调用UserEditBox对象的Set方法将“John”这个字符串赋给该对象。
脚本中同样可以使用VB中控制语句,如If…Then…EWFor…Next等
脚本不区分大小写
比如,下面两行代码是可以通用的:
Browser(&Mercury&).Page(&Find a Flight:&).WebList(&toDay&).Select &31&
[size=10.5pt]browser(&mercury&).page(&find a flight:&).weblist(&today&).select &31&
脚本中的字符串常量要用双引号括起来
比如下面一行代码:
Browser(&Mercury&).Page(&Find a Flight:&).WebList(&toDay&).Select &31&
网站名—Mercury,网页名---Find a Flight,控件名---toDay,控件选项---31,都用引号以上,表示它们都是字符串。
QTP专家视图方法大全
一.对象的方法
Activate:object.Activate [Item]
&&&&&&&& Item—列表中选择(名字:用引号;数字索引:不带引号;非必填项)
&&&&&& 例1:Browser(&Demo of Vo Object&).Page(&Demo of Vo Object&)
.ActiveX(&VoDemoFormX&).VirtualList(&list&).Activate 3
&&&&&&&&&&&&& 激活list目录下中的第四项
&&&&&& 例2:Dialog(&Login&).Activate
激活该页面
CaptureBitmap:object.CaptureBitmap FullFileName, []
保存某一界面到本地51Testing软件测试网d&S&Y#Sq&YR Cd,C
&&&&&&&& FullFileName—文件的保存绝对路径可以为变量(必填项;后缀名不能少)
&&&&&& OverrideExisting—布尔值(1或0;true或false;非必填项)
&&&&&& 例:Dialog(&Login&).CaptureBitmap &E:\tupian.bmp&,True
&&&&&& 将运行时的窗口用bmp格式保存本地
CheckProperty:object.CheckProperty (PropertyName, PropertyValue, [])
将对象的属性的实际值与预期值相比;一致返回true否则false
&&&&&& PropertyName—属性名称(用双引号,必填项)
&&&&&&&& PropertyValue—预期属性值(用双引号,必填项)
&&&&&& TimeOut—设置超时时间(不用引号,非必填项)
&&&&&& 例:a=Dialog(&Login&).CheckProperty(&height&,&205&,10)
&&&&&& 如果该对象的height属性值为205则a=true否则a=false
ChildObjects:object.ChildObjects ([Description])
返回一个页面/窗口的所有匹配的子对象
&&&&&& Description—要匹配对象的条件(非必填项)
&&&&&& 例: Set MyDescription = Description.Create() ‘设置描述性对象:
MyDescription(&html tag&).Value = &INPUT& '创建需寻找对象的属性
MyDescription(&type&).Value = &checkbox& '创建需寻找对象的属性
MyDescription(&name&).Value=&selectedIds&'创建需寻找对象的属性
'指定在该页面下符合上述条件的控件
Set Checkboxes = Browser(&test&).Page(&onsale&).ChildObjects(MyDescription)
NoOfChildObjs = Checkboxes.Count '指定符合条件对象的数量
For Counter=0 to NoOfChildObjs-1 '根据得到的属性,进行批量操作
&&&&&&& Checkboxes(Counter).Set &ON&&'对该类型的数据赋值
Click:object.click
Close:object. Close
DblClick:object. DblClick
例:Browser(&Demo of Vo Object&).Page(&Demo of Vo Object&).ActiveX(&VoDemoFormX&).
VirtualButton(&button&).DblClick
Drag:object.Drag X, Y, []
拖拽对象到指定位置
—指定基于最上层对象的左上角的X轴的数值(必填项,整数)
Y—指定基于最上层对象的左上角的Y轴的数值(必填项,整数)
BUTTON—1个预定义的常量或数字(非必填项)
Drop:object.Drop X, Y, [BUTTON]
X—指定基于最上层对象的左上角的X轴的数值(必填项,整数)
Y—指定基于最上层对象的左上角的Y轴的数值(必填项,整数)
BUTTON—1个预定义的常量或数字(非必填项)
GetTOProperty():取得仓库对象的某个属性的值
GetTOProperties():取得仓库对象的所有属性的值
GetROProperty():取得实际对象的某个属性的值
SetTOProperty():设置仓库对象的某个属性的值
(注:RO=TO=testtimeobject)
例:buttonNum = CInt(JavaWindow(&Test&).JavaEdit(&Record Num&).GetROProperty(&value&))
&&&&&&&&&&&&&&&&&& (其他类似)
GetTextLocation:TextUtil.GetTextLocation(TextToFind,
hWnd, Left, Top, Right, Bottom[, MatchWholeWordOnly])
&获取对象的坐标
例:'获取&Generate Report&文本在WinObject(&Menu&)中的坐标范围,
‘并返回给L(left),T(top),R(right),B(bottom)
VbWindow(&Window&).WinObject(&Menu&).GetTextLocation strText,L,T,R,B,True
'点击该文本所在坐标区域的正中心位置
VbWindow(&Window&).WinObject(&Menu&).Click (L+R)/2, (T+B)/2
GetVisibleText:object.GetVisibleText ([Left], [Top], [Right],
返回从指定区域的文本。
Left—左坐标内的对象的窗口搜索范围。
Top—顶部的搜索区域协调对象的窗口。(非必填项)
Right—右边的坐标内的对象的窗口搜索范围。(非必填项)
Bottom—底部坐标搜索范围内的对象的窗口。(非必填项)
Maximize:object.Maximize
窗口最大化
窗口最小化
MouseMove:object.MouseMove X, Y
移动鼠标指针到对象指定的位置。
X—x坐标的鼠标指针,相对于上对象的左上角。
Y—y坐标的鼠标指针,相对于上对象的左上角。
Move:object.Move X, Y
移动对话框到屏幕上指定的对应位置。
X—x坐标的鼠标指针,相对于上对象的左上角。
Y—y坐标的鼠标指针,相对于上对象的左上角。
Resize:object.Resize Width,
调整对话框大小到指定的尺寸。
Height—高度。整数值。窗口的新宽度,以像素为单位。
:object.Restore
恢复对话框原来的大小。
ToString:object.ToString
返回一个字符串,包含当前测试对象的属性值。
Type:object.Type KeyboardInput
在对象类型指定的字符串。
micCtrlDwn按下Ctrl键。&&&&&&&&&&micCtrlUp释放Ctrl键。
micLCtrlDwn按下左Ctrl键。&&&&&&&micLCtrlUp释放左Ctrl键。
micRCtrlDwn按下右Ctrl键。&&&&&&&micRCtrlUp释放右Ctrl键。
micAltDwn按下Alt键。&&&&&&&&&&&micAltUp释放Alt键。
micLAltDwn按下左Alt键。&&&&&&&&micLAltUp释放左Alt键。
micRAltDwn按下右边的Alt键。&&&&micRAltUp释放右边的Alt键。
micShiftDwn按下Shift键。&&&&&&&&&micShiftUp释放Shift键。
micLShiftDwn按下左边的Shift键。&&micLShiftUp释放左Shift键。
micRShiftDwn按下右Shift键。&&&&&&micRShiftUp释放右Shift键。
micIns按下INSERT键。--插入键
micDel按下Delete键。
micHome按下Home键。
micEnd按下End键。
micPgUp按下Page up键。
micPgDwn按下Page Down键。
micUp按下向上键。
micDwn按下向下键。
micLeft按下向左键。
micRight按下右键。
micEsc按下Esc键。
micBack按下Backspace键。
micReturn按下回车键。
micTab按下Tab键。
micBreak按下Break键。
micPause按下暂停键。
micPrintScr按下Print Screen键。
micWinLogoDwn按下Windows徽标键。&&&&&&micWinLogoUp释放的Windows徽标键。
micLWinLogoDwn按下左边的Windows徽标键.micLWinLogoUp释放左Windows徽标键。
micRWinLogoDwn按下右边的Windows徽标键.micRWinLogoUp释放右Windows徽标键。
micAppKey按下应用程序键。
Mic(F1~F12)按F1~F12键。
micNumLockOn打开Num Lock。&&&&&&&&&&&&&&&&&&micNumLockOff关闭的Num
Lock。--小键盘
micCapsLockOn打开大写锁定。&&&&&&&&&&&&&&&&&&micCapsLockOff关闭大写锁定。
micScrollOn打开滚动锁定。&&&&&&&&&&&&&&&&&&&&&&&&&&micScrollOff关闭滚动锁定。
WaitProperty:object.WaitProperty (PropertyName, PropertyValue,
等待至指定的对象属性达到或超过规定值,然后再继续下一个步骤指定的超时。
PropertyName—对象的属性名(必填项)
PropertyValue—该属性要达到的值或条件(必填项)
[TimeOut])—超时时间(选填)
例:Dialog(&Login&).WaitProperty &abs_x&, 123, 10000
当对象login的abs_x的值为123时再执行后续步骤;最大等待时间为10S
Exist:object.Exist()
检查对象存在。
[Timeout]—超时设置(选填项)
例:判断按钮是否存在;如果存在则给出提示
If Browser(&Demo of Vo Object&).Page(&Demo of Vo Object&).ActiveX(&VoDemoFormX&)
.VirtualButton(&button&).Exist Then
msgbox(&The object exists.&)
二.datatable的方法
AddSheet:DataTable.AddSheet(sheetname)
创建新的工作表
SheetName—新的工作表名称
例:DataTable.AddSheet (&MySheet&).AddParameter(&Time&, &8:00&)
在运行时在datatable中新建的一个MySheet工作表。
DeleteSheet:DataTable.DeleteSheet
在测试运行时删除指定的工作表
SheetID—要删除的工作表的标识符
例:DataTable.DeleteSheet &MySheet&
使用DeleteSheet方法来删除表“MySheet”。
:DataTable.Export()
在测试运行过程中导出datatable数据。
FileName—要导出的工作表名称
例:DataTable.Export (&C:\flights.xls&)
导出datatable中所有数据至指定路径。
:DataTable.ExportSheet(FileName,)
在测试运行过程中导出datatable中指定的sheet表到指定的位置。
FileName—保存导出数据的绝对路径
DTSheet—变量的名称或运行时数据表或你要导出的索引(指数值从1开始)
例:DataTable.ExportSheet &C:\name.xls& ,1
保存的运行时datatable中的第一页到name.xls文件。
:DataTable.GetCurrentRow(全局)
例:row = DataTable.GetCurrentRow
Reporter.ReportEvent 1, &Row Number&, row
检索当前正在运行时数据表中使用的行,并将其写入报告。
:DataTable.GetRowCount
返回datatable数据表中单列最大行数
例:rowcount = DataTable.GetRowCount
Reporter.ReportEvent 2, &There are & &rowcount, &rows in the data sheet.&
返回数据表的最大行数;并显示在报告中
:DataTable.GetSheet()
返回运行时数据表的&MySheet&工作表,以便向其中添加参数。
SheetID—要返回的工作表名称。该表ID可以是表名称或索引(指数值从1开始)
例:a=DataTable.GetSheet (&MySheet&).AddParameter &Time&, &8:00&
返回mysheet表同时向表里面添加参数;a的值为“8:00”
:DataTable.GetSheetCount
例:sheetcount = DataTable.GetSheetCount
返回datatable数据表的sheet总数。
:DataTable.GlobalSheet
返回在运行时数据表(全局表)
向全局表添加一个参数并返回;ParamValue的值为“5:45”
注:“time”:sheet表中的列名;“5:45”:time列中的参数
返回当前(活动)的运行时数据表的本地表。
向Action表(局部)添加一个参数并返回;ParamValue的值为“5:45”
注:“time”:sheet表中的列名;“5:45”:time列中的参数
:DataTable.Import()
运行时导入指定的Excel文件的数据表。
FileName—
例:DataTable.Import (&C:\flights.xls&)
导入指定路径的文件到datatable
:DataTable.ImportSheet(FileName,
SheetSource, SheetDest)
运行时导入指定的Excel文件中的指定的sheet数据表。
FileName—导入文件的绝对路径。
SheetSource—要导入表的变量名称或文件索引(指数值从1开始)。
SheetDest—要替换变量的名称或数据表中的表。(导入后存放的空间)
,1,&Action1&
&导入指定数据表至指定的action数据表中
注:1:sheet的索引;可以是sheet名如“sheet1”同样效果
&&&&&&&&&&&&&&&&&& Action:指定的数据表
:DataTable.RawValue ParameterID
在运行时获取当前行指定单元格的参数值
ParameterID—列的变量名或索引(指数从1开始)
SheetID—要返回工作表;可以是表名称或索引(默认全局表)
返回指定列的参数值
&&&&&&&& Data:列名;action:数据表名
:DataTable.SetCurrentRow(RowNumber)
设置当前active的行数(第一行为1)。
RowNumber—行号
例:DataTable.SetCurrentRow(tb_i+1)
DataTable.GetSheet(&Action1&). SetCurrentRow(tb_i+1)
此命令可在循环运行中不断指向下一行数据
DataTable.SetCurrentRow (2)
指向第二行
设置向下一行
SetPrevRow:DataTable.SetNextRow
设置向下一行
:DataTable.Value(ParameterID [,])(查找值)
&&&&&&&& && DataTable.Value(ParameterID [, SheetID])=NewValue(设置单元格的值)
获取或这只单元格的值
ParameterID—列名
SheetID—sheet名(非必填项,默认为全局变量global)
例:DataTable.Value(&目的地&,&Action1&)=&纽约&
a=datatable.Value(&目的地&,&Action1&)
注:以上操作大多数为全局操作global若要对单个sheet操作可以使用下列方法DataTable.GetCurrentRow
Reporter.ReportEvent 1, &Row Number&, row
中间加【.GetSheet(&Sheetid&)】
执行for循环的方法
For&i=0&to&datatable.GetSheet(&Goods&).GetRowCount-1&'定义循环执行次数
&'要循环的测试脚本 &&
&DataTable.GetSheet(&Goods&).SetNextRow&'获取DataTable中的下一行数据 &&
看过本文的人也看了:
我要留言技术领域:
取消收藏确定要取消收藏吗?
删除图谱提示你保存在该图谱下的知识内容也会被删除,建议你先将内容移到其他图谱中。你确定要删除知识图谱及其内容吗?
删除节点提示无法删除该知识节点,因该节点下仍保存有相关知识内容!
删除节点提示你确定要删除该知识节点吗?I’ve been doing some digging into QTP’s test-objects, hoping to find some undocumented methods and techniques. Armed with the power of ,
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 ,
re-links the test-object to the runtime object. Especially useful in a web environment, after a page refresh.
All Objects:
Description
.MakeObjVisible
Scrolls the object into view (if needed). Similar to the documented .MakeVisible method for ActiveX objects
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.
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.):
Description
Presumably submits a form, if activated on the relevant object
.MouseOver
Similar to firing the OnMouseOver event.
Standard Windows
All Objects:
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.
Description
Seems to be exactly like the regular .Set method. However, Neither function uses the other (checked with RegisterUserFunc)
WinButton:
Description
Seems to be exactly like the regular .Click method. However, Neither function uses the other (checked with RegisterUserFunc)
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:
Description
ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly, BUTTON, DoubleClick)
Same as in Standard Windows.
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.
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:
Description
Seems to be exactly like the regular .Click method. However, Neither function uses the other (checked with RegisterUserFuc)
All Objects:
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.
如何查看QTP对象的属性列表
查看QTP对象的属性列表方法有两个,以下分别说明。
方法一:对象仓库绿色加号图标
通过单击&录制&按钮,将对象录制到对象仓库中,依此单击&Resources&--&&Object Repository...
QTP识别对象的3中类型属性
QTP识别对象的3中类型属性
1. 强制属性(强制属性总是被捕捉并保存,即使没有其中的一些属性,对象也能识别也不例外)
2. 辅助属性(假如强制属性不足以唯一识别某对象,那么可以依次添加辅助属...
QTP对象的方法(一)
一.对象的方法
Activate:object.Activate [Item]
Item—列表中选择(名字:用引号;数字索引:不带引号;非必填项)
例1:Browser(&Demo ...
QTP运行对象属性和对象库属性的区别和用法
SetToProperty :
修改对象库中对象的属性
GetRoProperty :
获取对象库中对象的属性
GetToProperty ...
自动化测试工具QTP:维护对象库、获取对象属性、智能识别、参数化若干问题
最近有一个项目,需要批量生产测试数据。原本打算使用LR来自动生成,但是里面涉及到动态数据的获取,而开发不能及时过来说明该取哪些数据,于是放弃使用LR,而改用QTP进行UI操作的重放来生成数据。
当遇到一些网站是由一些使用javascript生成的控件组成时,使用QTP的对象侦查器往往不能识别,会统统都识别成WebElment。这时可以使用XPath作为属性标识对象。
1.要对QTP/UFT...
TO是Test Object的简称,RO是Runtime Object简称,既用来区分仓库对象和实际对象,又用来区分对象的封装接口和自身接口。
从实际作用上来看,应该说TO就是是仓库文件里定义的仓库...
在qtp测试中,如果出现页面对象获取不到的情况,我们可以适用描述性编程等方法强制获取页面元素,那么如果碰到使用以上方法仍然无法完成页面元素的操作的情况又该怎么办呢。我最近就碰到了这个问题。场景为在一个...
参考文章地址:http://www.51testing.com/?26649/action_viewspace_itemid_608.html
在自动化测试当中,有时为了模拟真实效果,或者为...
确定对象的常见方法
1.最普通的方法
Browser(&百度一下,你就知道&).Page(&百度一下,你就知道&).WebEdit(&wd&).Set &Eric1991&
注:该方法需要把对应...
没有更多推荐了,qtp&问题汇总(不断更新)&一&
一、Cannot find the
"shoujian.projectname" object's parent "10_2" (class Frame). Verify
that parent properties match an object currently displayed in your
application.问题的解决。
这个问题真是郁闷,其实产生的主要原因是:在录制脚本的时候,qtp没有识别出来框架Frame中的对象,回放时找不到对象出错。
解决办法:通过object spy
识别对象 并将其添加到对象库;然后在录制点击对象的一段脚本(或者自己写),再次回放就ok了。
二、注意:datatable.Importsheet
"D:\test\USER_INFO.xls",1,"Action1"
中,"Action1"一定要加双引号,要不然默认导入到Global中。
三、自动启动qtp的vbscript脚本。
qtapp=createobject("QuickTest.application")
qtapp.Launch
qtapp.visible=true
用法:将脚本卸载记事本文件中,文件格式保存为.vbs
点击直接运行。就可以自动启动qtp。
四、描述性编程中出现“The
“[WinEdit]”object's description ,matches more than one of the
objects currently displayed in your appliction.Add addtional
properties to the objects ddescription in order to uniquely
identify the object.”中问题的解决。
这个问题看起来其实很简单就是在QTP描述过程中,发现匹配该对象的属性多于1个,因此无法正确匹配,所以QTP报错。错误如图下:
问题解决方法:
添加更多的对象属性,以便正确匹配,在对象查看器点击该对象(我的是password对象),点击,查看对象的属性,添加更多的属性,如:window
id 等。同时将脚本修改为:
Dialog("Login").WinEdit("attached text:=Password:","window id:=3001").Set
"cheers_lee"
注意红色字体部分,我是同个两个属性匹配WinEdit的,一个是attached
text另一个是window id。再次运行脚本,测试通过OK!强调的是attached
text和window id 是对象的属性,通过对象查看器可以看到。
五、修改中对象的默认识别属性
在里面 ,选择Tools
--& Object Identification...选择Web,找到&&WebCheckBox,看看
默认的识别WebCheckBox
时使用的是哪些。可以修改识别WebCheckBox的。
注意: 修改只对以后录制的脚本起作用。
六、QTP如何鼠标右键菜单
以附带的订票网站sample为例,edit控件username鼠标右键,点击paste(第4个菜单项)
cur_replay_type = Setting.WebPackage("ReplayType")
Setting.WebPackage("ReplayType") = 2
("").Page("Welcome:
Tours").WebEdit("userName").Click 5,4, micRightBtn
Setting.WebPackage("ReplayType") = cur_replay_type
Set WshShell = CreateObject("Wscrīpt.Shell")
For i = 1 To index
& & WshShell.sendKeys
WshShell.sendKeys "{ENTER}"
Set WshShell = nothing
七、如何设置让对象库不产生重复对象
tools --options---web
---page/frame optinons
都选择第二项.就OK了.
八、QTP中用代码连接数据库
Set Conn =
CreateObject("ADODB.Connection" )
str="DRIVER=Oracle in OraHome92;SERVER=192.168.0.1;DBQ=user
id= password=test"
Conn.open str
Set Rs = CreateObject ("ADODB.Recordset" )
sql = "select * from user_table t where table_name = 'XXX' "
Rs.open sql,conn',1,3
九、QTP测试页面字体颜色的办法
set ōbj = ().Page().WebElement().Object
' Get the&&object
set iStyle= obj.currentstyle
' Get the attribute
sColor = iStyle.color
十、下拉菜单不能回放的解决方法
在录制时,比如打开记事本,点击下拉菜单
"文件"--&"退出";
回放时会出现
windows("记事本").click 193,117
windows("记事本").winmenu("ContextMenu").Select "文件:退出"
默认录制方式是无法录制下拉菜单的,必须修改设置后再录制
修改设置如下:
在tools -& web event recording configuration 点击custom
settings... 展开Web objects,
选种webelement,点击event -& add -&
onmouseover 。并确定在record栏内,状态是enabled。
然后再重新录制你的脚本。
执行录制后的脚本,无法回放成功,这是因为脚本只录制了鼠标的onmouseover 事件,却没有录制click事
件,所以脚本录制完后要手动添加click事件。
十一、QTP中如何识别带参数的链接?
中如何识别带参数的链接?比如:"("browser").Page("page").Link("href:=http://www.xxx.test/file/upload.php?matchable=0"
特殊字符都需要用转义字符""来进行转义。
十二、如何让QTP运行时自动产生提示信息并自动确定?
Set WshShell =
CreateObject("Wscrīpt.Shell")
& WshShell.Popup "", 2, "标题内容"
十三、QTP回放的过程中出现禁止运行控件提示的解决方法
修改设置如下:toos--&options..--&Active
Screen--&Advanced--&点选Load ActiveX
十四、从QC自动启动qtp如何自动加载插件
'此函数用于加载指定所有的插件,若要运行Test可自己加个qtApp.Test.Run
Function Load_Addins(testPath)
&&&Dim qtApp 'As
QuickTest.Application
blnNeedChangeAddins
arrTestAddins
&&&Set qtApp =
CreateObject("QuickTest.Application")
&&&arrTestAddins
= qtApp.GetAssociatedAddinsForTest(testPath)
&&&blnNeedChangeAddins
&&&For Each
testAddin In arrTestAddins
qtApp.Addins(testAddin).Status &&
"Active" Then
blnNeedChangeAddins = True
&& &End If
qtApp.Launched And blnNeedChangeAddins Then
qtApp.Quit
blnNeedChangeAddins Then
blnActivateOK
&blnActivateOK =
qtApp.SetActiveAddins(arrTestAddins, errorDescrīption)
&& &If Not
blnActivateOK Then
ErrorLog(errorDescrīption)&&'这里是调用自己的函数,可替换为自己的或注释掉
&Wscrīpt.Quit
&& &End If
qtApp.Launched Then
&qtApp.Launch
&&&qtApp.Visible
&&&qtApp.Open
'可在此加入qtApp.Test.Run来运行Test
&&&Set qtApp =
End Function
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 对统计数据的属性特征进行分类标示 的文章

 

随机推荐