惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 飞儿

要让IT收入比重越来越小 准备买房了? 想写一篇小说 如何做好测试建议清单 看新闻的时间用的太多了 robot经验整理及验证点的说明 robot取excel表格参数脚本 猪肉未来还是会涨的 回归IT 2008,又是新的一年 TD各版本的汉化插件下载 QTP基础代码(转) 自动码流转换(ROBOT) 数据库连接(ROBOT) 大小写转换(ROBOT) 行走在消逝中 写的痛快 常用ROBOT函数详解 沉下来,沉下来,别让自己太浮躁
QTP参考代码框架
飞儿 · 2007-08-22 · via 博客园 - 飞儿

Dim logdata,sou,ExpectedResult1,ExpectedResult2,ExpectedResult3,ExpectedResult4,ExpectedResult5,ExpectedResult6
sou="F:\work\protocol\bintext\bin\_Debug.log"                                                                                                                              'log文件地址自己填加
'--------------------
Function readlog(sou)
Dim fso,f1,f2
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.OpenTextFile(sou)
f2 = f1.ReadAll
f1.close
readlog=f2
End Function
'-----------------------------------------------------------
Function getdata(x,y)
getdata = CStr(ExcelSheet1.Cells(x, y))
End Function
'---------------------------------------------------------------------------
Function savedata(x,y,z)
ExcelSheet.ActiveSheet.Cells(x,y).Value =z
End Function
'-------------------------------------------------------------
Sub over()
 Set shell = Nothing
Set oShell = Nothing
Set ExcelSheet = Nothing
Set ExcelSheet1 = Nothing
''Excel.Application.Quit
'ExcelSheet.Application.Quit
End Sub
'-----------------------------------------------------------
Dim Excel,ExcelSheet,ExcelSheet1,ExcelSheet2
Set Excel=CreateObject("Excel.Application")
Set ExcelSheet = Excel.Workbooks.Open("F:\work\protocol\qtp\协议测试数据驱动表.xls")        '驱动表格地址自己添加
Set ExcelSheet1= ExcelSheet.Worksheets("测试数据")
ExcelSheet.Application.Visible = True
'------------------------------
Dim oShell,shell,black
SystemUtil.Run "F:\work\protocol\bintext\bin\test.bat","","F:\work\protocol\bintext\bin\" ,"open"  
'测试程序路径和QTP工作路径自己填加修改
Set shell=createobject("Wscript.shell")
'----------------------------------------------------------
'登陆过程
Sub login(userx,usery,pwdx,pwdy,resultx,resulty,savex,savey)  
shell.sendkeys "login:" & getdata(userx,usery) & "," & getdata(pwdx,pwdy) & ",5222 {enter}"
ExpectedResult1 = getdata(resultx,resulty)
logdata = readlog(sou)
If InStr(logdata, ExpectedResult1) Then
call savedata(savex,savey,"PASS")
Else
call savedata(savex,savey,"FAIL")
End If
End Sub
'-------------------------------------------------------------
'   shell.sendkeys 作用是在cmd中输入字符串  如下
'预期结果--可以有任意多的预期结果,变量在顶部填加。
'   getdata(x,y)      用来从表格取数据  x为横向列数  y为纵向列数
'   savedata(x,y)   用来把数据记录到表格中  x为横向列数  y为纵向列数
'检查 --  每次检查预期结果的时候需要从log中取得数据   logdata = readlog(sou)   的作用就是从输入的路径取log数据
'--------------------------------------------------------------------------------------
'函数表
'           login(userx,usery,pwdx,pwdy,resultx,resulty,savex,savey)          userx 表示用户名在excel上的横坐标,usery表示用户名在excel上的纵坐标,依次类推
'  其他函数过程自己写


'-------------------------------------------------------------------------------------

Call login(5,6,5,7,5,12,5,16)    '举例


Call over()