您的位置:首页 > 其它

016专家视图测试脚本开发_utility对象

2014-10-28 16:13 323 查看

utility对象
(1)这个例子是:Extendtest
使用Extend对象加载DLL,我们可以使用它来丰富windows api函数,能够编写更为强大和灵活的测试代码

实例代码:

'声明FindWindow方法,调用user32.dll中的FindWindowA函数
Extern.Declare.micHwnd,"FindWindow","user32.dll","FindWindowA",micString,micString

'声明SetWindowText方法
Extern.Declare miclog,"SetWindowText","user32.dll","SetWindowTextA",micHwnd,micString

'获取记事本的窗口的句柄
hwnd = Extern.FindWindow("Notepad",vbNullString)

If hwnd = 0 Then
MsgBox"未能找到记事本窗口"
End If
'改变记事本窗口的标题
res = Extern.SetWindowText(hwnd,"Hello world")

结果:当记事本打开的时候记事本的标题是”Hello world“,但是有如下的问题:



(2)SystemUtil对象:调出计算器程序
如:
'控制应用程序和进程
Systemutil.Run"calc"
(3)reporter对象:可用于发送信息到测试结果文件,这对于测试结果分析比较有用。可以使用Reporter对象的ReportEvent方法来向测试结果写入一个事件
如:
Reporter.ReportEvent micDone,"开始学习QTP","学习QTP很快乐"
Reporter.ReportEvent micFail,"开始学习QTP","学习QTP很痛苦"

二、参数化中:变量放入data table和随机数。

Window("Flight Reservation").ActiveX("MaskEdBox").Type "121214"
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("from_Item", dtGlobalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("to_Item", dtGlobalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select RandomNumber(0, 100)
Window("Flight Reservation").WinEdit("Name:").Set "tom"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").Move 414,180

但选择随机数的时候提示下面的错误:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: