51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 1829|回复: 2
打印 上一主题 下一主题

[求助] qtp多循环执行用例,出现can'open the test

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-7-17 15:36:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
qtp多循环执行用例,出现can'open the test
         
        Do While CStr(timeing)<>mid(CStr(time()),1,5)  '到指定执行时间
                 wscript.sleep 500
        Loop
               
       
                        myString = ".*\\([^\:]+)"
                        err_flag = 0
                       
                       
                        qtApp.Launch ' Start QuickTest
                        WriteToFile(Time&"----QTP is running test! Ant's request stop the current test. The newset vesion test start!----")   ’写日志到指定txt文本中
                        qtApp.Visible = false ' Make the QuickTest application visible
                        ' Set QuickTest run options
                        qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
                        qtApp.Options.Run.RunMode = "Fast"
                        qtApp.Options.Run.ViewResults = False
                       
                        qtApp.Options.Run.CaptureForTestResults = "OnWarning"
                       
                        set fso = CreateObject("scripting.filesystemobject")
                       
                        looktype = "0"
                        For i = 1 To run_times
                        Set f=fso.OpenTextFile("F:\test.txt", 1, false)     'test.txt中存储需要执行的用例的执行路径
                                Do While f.AtEndOfStream <> True
                                       
                                        retstring = f.ReadLine
                                        Set myReg = New RegExp
                                        myReg.Pattern = myString
                                        myReg.IgnoreCase = True
                                        myResult = myReg.Replace(retstring,"$1")
                                        
                                      
                                        qtApp.Open retstring, True ' Open the test in read-only mode
                                        ' set run settings for the test
                                        Set qtTest = qtApp.Test
                                      
                                        
                                        Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
                                        
                                        qtResultsOpt.ResultsLocation =  retstring&"\Res"&i
                                                                   
                                        wrongresult = retstring&"\Res"&i
                                                       
                                                       
                                        '判断是否有Resi或者本次循环的报告结果文件夹,如果有,将其删除
                                        Set fso=createobject("scripting.filesystemobject")
                                        If(fso.FolderExists(wrongresult)) Then
                                                fso.deleteFolder wrongresult
                                                If(fso.FileExists(wrongresult&".zip")) Then
                                                fso.DeleteFile wrongresult&".zip"              
                                            End If
                                        End If            
                                        
                                        Set pDefColl = qtApp.test.ParameterDefinitions
                                        Set rtParams = pDefColl.GetParameters()
                                        '------------------------------------------------------
                                        '启动一个监控进程
                                        'Set shell1 = CreateObject("wscript.shell")
                                        'shell1.Run "wscript.exe F:\shutdownqtp.vbs"
                                                       
                                        qtApp.test.Run,True,rtParams 'Run the test
                                        
                                                                        
                                        '如果正常执行完成,kill掉监控进程
                                        'Set shell = createobject("wscript.shell")

                                        'shell.run "taskkill /f /im WScript.exe",0
                                        looktype = "0"
                                        '-------------------------------------------------------
                                        WriteToFile("                              ")
                                        WriteToFile(Time&wrongresult&" is running")
                                        If rtParams.Item("OutParam1").Value = False Then
                                                tmp = filezipsendmail(i,wrongresult,smstomail)
                                               
                                                tmp = send_mobile(smstomobile,wrongresult)
                                                If tmp="1" Then
                                                        WriteToFile(Time&wrongresult&" 短信发送成功")    ‘发送短信通知,如果执行用例失败
                                                Else
                                                        WriteToFile(Time&wrongresult&" 短信发送失败")   ‘发送报告到邮件,如果执行用例失败
                                                End If
                                               
                                                                WriteToFile(Time&wrongresult&" is failed")
                                                        Else
                                                                WriteToFile(Time&wrongresult&" is succ")
                                        End If
                                     
                                        
                                        tmp = closeie()
                                        WriteToFile("                              ")
                                        If(fso.FolderExists(wrongresult)) Then
                                        fso.deleteFolder wrongresult
                                        End If
                                        wscript.sleep 5000
                                Loop
                                
                       
                        f.close
                        Next
                       
                        qtTest.Close
                       
                       
                        'qtTest.Close ' Close the test
                        Set qtResultsOpt = Nothing ' Release the Run Results Options object
                        Set qtTest = Nothing ' Release the Test object
                        Set qtApp = Nothing ' Release the Application object
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2009-7-17 15:41:19 | 只看该作者
其中
        '启动一个监控进程
        'Set shell1 = CreateObject("wscript.shell")
        'shell1.Run "wscript.exe F:\shutdownqtp.vbs"
                                                       

                                                       
                                                       
                                                       
         qtApp.test.Run,True,rtParams 'Run the test
                                        
                                        
        '如果正常执行完成,kill掉监控进程
        'Set shell = createobject("wscript.shell")
        'shell.run "taskkill /f /im WScript.exe",0

这段代码本意是想要启动另一进程A,对qtp进行监控,如果qtp的执行超过半个小时,则杀掉qtp进程,并且重起qtp,如果没有超过半小时,还有一条进程B将A进程杀掉
执行的时候,发现qtp被杀掉后再重起是不能重起的,猜测其原因,可能是杀掉qtp进程后,它的某些东西没有来得及写道内存中,导致再次重起qtp时出现问题。
此问题也请教高人指教,或者有没有其它办法对qtp进行监控,如果qtp本身程序crash掉了。
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2009-7-17 16:03:55 | 只看该作者
循环执行用例,执行到3次或4次的时候就会出现这个错误can't open test,
请各位指导下,有任何意见都欢迎给出,集思广益哈~~~~
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-5-6 04:40 , Processed in 0.071143 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表