海是我向往的地方,吸纳和咆哮是他的魅力!!!

QTP学习

上一篇 / 下一篇  2007-12-03 12:46:48

修改QTP中对象的默认识别属性

WebCheckBox为例。
QTP里面 ,选择Tools --> Object Identification...Environment选择Web,找到  WebCheckBox,看看QTP默认的识别WebCheckBox对象时使用的是哪些属性。可以修改识别WebCheckBox对象属性
注意: 修改只对以后录制的脚本起作用。

QTP如何测试鼠标右键菜单

QTP附带的订票网站sample为例,edit控件username鼠标右键,点击paste(第4个菜单项)

cur_replay_type = Setting.WebPackage("ReplayType")
Setting.WebPackage("ReplayType") = 2
Browser("Browser").Page("Welcome: Mercury Tours").WebEdit("userName").Click 5,4, micRightBtn
Setting.WebPackage("ReplayType") = cur_replay_type

index=4
Set WshShell = CreateObject("Wscrīpt.Shell")
For i = 1 To index
    WshShell.sendKeys "{DOWN}"
Next
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=testdb;user id=test; 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 =Browser().Page().WebElement().Object
' Get the  object
set iStyle= obj.currentstyle
' Get the attribute
sColor = iStyle.color
 

下拉菜单不能回放的解决方法

在录制时,比如打开记事本,点击下拉菜单 "文件"-->"退出";
回放时会出现 object not visible ;
windows("记事本").click 193,117
windows("记事本").winmenu("ContextMenu").Select "文件:退出"

QTP默认录制方式是无法录制下拉菜单的,必须修改设置后再录制
修改设置如下:
在tools -> web event recording configuration 点击custom settings... 展开Web objects,
选种webelement,点击event -> add -> onmouseover 。并确定在record栏内,状态是enabled。
然后再重新录制你的脚本。
执行录制后的脚本,无法回放成功,这是因为脚本只录制了鼠标的onmouseover 事件,却没有录制click事
件,所以脚本录制完后要手动添加click事件。
 

QTP中如何识别带参数的链接?

QTP中如何识别带参数的链接?比如:"Browser("browser").Page("page").Link("href:=http://www.xxx.test/file/upload.php?matchable=0"

特殊字符都需要用转义字符"\"来进行转义。

如何让QTP运行时自动产生提示信息并自动确定?

Set WshShell = CreateObject("Wscrīpt.Shell")
       WshShell.Popup "123456789", 2, "标题内容"
 

QTP回放的过程中出现禁止运行控件提示的解决方法

修改QTP设置如下:toos-->options..-->Active Screen-->Advanced-->点选Load ActiveX controls
 

从QC自动启动qtp如何自动加载插件

'此函数用于加载指定Test所有的插件,若要运行Test可自己加个qtApp.Test.Run
Function Load_Addins(testPath)
        Dim qtApp 'As QuickTest.Application
        Dim blnNeedChangeAddins
        Dim arrTestAddins
        Set qtApp = CreateObject("QuickTest.Application")
        arrTestAddins = qtApp.GetAssociatedAddinsForTest(testPath)
        blnNeedChangeAddins = False
        For Each testAddin In arrTestAddins
            If qtApp.Addins(testAddin).Status <> "Active" Then
                blnNeedChangeAddins = True
                Exit For
            End If
        Next
        If qtApp.Launched And blnNeedChangeAddins Then
             qtApp.Quit
        End If
        If blnNeedChangeAddins Then
            Dim blnActivateOK
            blnActivateOK = qtApp.SetActiveAddins(arrTestAddins, errorDescrīption)
            If Not blnActivateOK Then
                Call ErrorLog(errorDescrīption)  '这里是调用自己的日志函数,可替换为自己的或注释掉
                  Wscrīpt.Quit
            End If
        End If
        If Not qtApp.Launched Then
            qtApp.Launch
        End If
        qtApp.Visible = True
        qtApp.Open testPath
'可在此加入qtApp.Test.Run来运行Test
        Set qtApp = Nothing
End Function
 

Cannot identify the object "xxx" (of class Window)问题的一般解决步骤

Cannot identify the object "xxx" (of class Window)是一个常见的错误,表示无法确定对象xxx。
一般的解决步骤如下:
1、用Object Spy查看一下对象xxx的运行时属性
2、在对象库中,找到相应的对象xxx,查看它的属性;
3、比较两个对象间属性的差异,这个差异就是造成此错误的原因。
 

TAG:

 

评分:0

我来说两句

Open Toolbar