当前位置:首页 » 网页前端 » qtp脚本
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

qtp脚本

发布时间: 2022-02-09 16:54:59

‘壹’ qtp测试脚本语言是什么

QTP是基于VBS脚本语言的,大部分VBS脚本都能在QTP上运行,只是在一些细节上略有不同,比如说VBS上停止用sleep,QTP上用wait。QTP的强大之处在于对程序窗口的操作,有很多针对窗体的属性、方法,这个是VBS所没有的。

‘贰’ QTP如何写脚本语言进行对象的双击操作

调用鼠标事件吧: FireEvent("参数")
参数:onclick —单击 onmousebover—鼠标停留 ondbclick—双击 onfocus—使获得焦点

例子:
Browser("XX").Page("XX").Link("XX").FireEvent("onclick")

‘叁’ QTP录了一个脚本、我想让他重复执行100次、怎么操作啊

1、如果有需要参数化的数据,将该数据参数化100次即可
2、如果没有需要参数化的,在脚本的data table中第一列输入100行数据(任意数据)即可
另:手动在data table中输入100行数据太麻烦,可以在脚本保存的目录下找到Default.xls,该文件即为data table表格,修改后保存,再重新打开脚本就可以看到修改后的数据

‘肆’ 如何使用QTP脚本的封装和调用方法

把QTP脚本封装起来,使其看起来一目了然! 简单介绍一下方法: '启动飞机订票系统 Sub flight() SystemUtil.Run "D:\Program Files\ Mercury Interactive\ QuickTest Professional \samples\flight\app\flight4a.exe","","D:\Program Files\Mercury Interactiv
把QTP脚本封装起来,使其看起来一目了然!
简单介绍一下方法:

'启动飞机订票系统

Sub flight()

SystemUtil.Run "D:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","D:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"

End Sub

'登录

Sub login()

Dialog("Login").WinEdit("Agent Name:").Set "cff100"

Dialog("Login").WinEdit("Password:").SetSecure ""

Dialog("Login").WinButton("OK").Click

End Sub

'插入订单

Function insertorder()

Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"

Window("Flight Reservation").WinComboBox("Fly From:").Select "London"

Window("Flight Reservation").WinComboBox("Fly To:").Select "Paris"

Window("Flight Reservation").WinButton("FLIGHT").Click

Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12538 LON 10:24 AM PAR 12:24 PM AF $162.40" 可以以数值代替如2

Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

Window("Flight Reservation").WinEdit("Name:").Set "cff100"

Window("Flight Reservation").WinRadioButton("Business").Set

Window("Flight Reservation").WinButton("Insert Order").Click

Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", Insert Done..., 10000

End Function

'退出

Sub logout()

Window("Flight Reservation").Close

End Sub

其实就是把脚本按操作分段。然后以过程(SUB.....END SUB)或函数(FUNCTION ....END FUNCTION)进行封装。

这样的脚本看上去一目了然,易理解也易于管理。

QTP函数过程的调用

以上面的QTP录制脚本的封装中的脚本为例:

Call 过程名/函数名

直接调用过程名/函数名

也以飞机订票系统为例。调用上面封装的过程/函数:

flight/call flight

login/call login

insertorder/Call insertorder

logout/Call logout

1. 调用SUB/FUNCTION方法是一样的……除了CALL调用如果有参数则需要使用括号将参数变量括起来。

2. SUB与FUNCTION的区别:SUB过程是没有返回值的.但是FUNCTION是可以有返回值的。
转载,仅供参考,祝你愉快,满意请采纳。

‘伍’ 请教 关于QTP的脚本语言

学工具需要从基础学起,先看书吧,看资料吧

‘陆’ QTP手写脚本的步骤是怎样的呢

录制和手写可以配合使用
我一般是先录制一个简单的操作,比如登录,然后打开要测试的页面,结束录制
回放检测有没有错误,
没有错误就开始手工写脚本增加操作步骤,如果有错误就调试脚本解决问题
不是每个脚本都需要用到对象库,有时适当使用描述性编程更有效率,这时是不需要使用对象库的
比如
这是应用对象库的脚本 Browser(“测试页面”).Page(“测试页面").WebEdit("测试按钮").Click
这三个对象都会在对象库中找到
描述性编程的脚本
Browser(“测试页面”).Page(“测试页面").WebEdit("innertext:=测试按钮").Click
WebEdit对象没在对象库中

‘柒’ QTP的2种脚本调用方法是什么

QTP的2种脚本调用方法是什么
我不知道你调用脚本是什么概念?在QTP中调用外部脚本?还是启动QTP脚本?
调用外部脚本,你可以采取VBS的程序去调用外部程序,或者你可以写COM接口,然后再QTP的中调用!
启动QTP脚本,你可以采取QTP的COM接口通过程序来调用
(3atesing有大量视频专门介绍QTP的各类实用模式的)
QTP的COM调用可参考:
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Launch QuickTest
qtApp.Visible = True ' Set QuickTest to be visible
' Open a test and get the "Login" action's object repositories collection
qtApp.Open "C:\Tests\Test1", False, False ' Open a test
Set qtRepositories = qtApp.Test.Actions("Login").ObjectRepositories ' Get the object repositories collection object of the "Login" action
' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find("C:\MainApp.tsr") = -1 Then ' If the repository cannot be found in the collection
qtRepositories.Add "C:\MainApp.tsr", 1 ' Add the repository to the collection
End If
' If InnerWnd.tsr is moved down the list - place it back at position 1
If qtRepositories.Count > 1 And qtRepositories.Item(2) = "C:\InnerWnd.tsr" Then ' If there's more than one object repository and InnerWnd.tsr is in position 2
qtRepositories.MoveToPos 1, 2 ' Switch between the first two object repositories
End If
' If Debug.tsr is in the collection - remove it
lngPosition = qtRepositories.Find("C:\Debug.tsr") ' Try finding the Debug.tsr object repository
If lngPosition -1 Then ' If the object repository was found in the collection
qtRepositories.Remove lngPosition ' Remove it
End If
' Set the new object repository configuration as the default for all new actions
qtRepositories.SetAsDefault ' Set object repositories associated with the "Login" action as the default for all new actions
'Save the test and close QuickTest qtApp.Test.Save ' Save the test qtApp.Quit ' Quit QuickTest Set qtRepositories = Nothing ' Release the action's shared repositories collection Set qtApp = Nothing ' Release the Application object

‘捌’ 编写的QTP脚本中如何调用其他的QTP脚本中自定义的函数

将你写的函数加入至 Associated Library Functiions

‘玖’ QTP脚本怎么强化

首先这不是个问题,QTP直接回放录制的脚本原本就基本相当于重复一次之前的手动操作,正常情况下就是按照原来既定的来走。也就是说你录的时候手动操作一次,回放的时候又做了一次同样的操作。

但一般来说我们在开始一次新的测试前,往往需要恢复测试场景,比如恢复测试数据库等方式来重置测试场景,确保回放时的场景状态和录制脚本时是一致的,这样才能比较好的完成回放过程。

若是希望用不同的数据来进行操作,那么可以对脚本做些最基本的增强,比如将"名称"参数化一下,用其它的指定名称或者随机字符串进行接下来的操作。