东莞微信网站建设信息,php网站开发实例教程书,网站建设与管理教学设计,高端网站制作多少钱今天工作的需求是要在录制一段web程序之前要调用plsql并执行一段数据库代码清空相关数据才能做web录制测试#xff0c;本来是想用QTP直接录制plsql的#xff0c;但是后来发现自己对qtp录制window application并不是很了解#xff0c;选定了 Automation菜单下的Record and Ru…今天工作的需求是要在录制一段web程序之前要调用plsql并执行一段数据库代码清空相关数据才能做web录制测试本来是想用QTP直接录制plsql的但是后来发现自己对qtp录制window application并不是很了解选定了 Automation菜单下的Record and Run Settings中的制定plsql程序的路径一录制竟然也代开了web的初始页面后来发现是要把web的Record and Run Settings中设置成第一个选项 Record and run on any browser才不弹出来了。后来发现竟然qtp录制plsql的脚本就像低级录制的脚本一样是用坐标表示的(Window(Oracle Logon).WinObject(test).Click 44,8)。回放一点反应都没有。不行时间紧迫我得另外想办法搞定这个plsql。直接用vbs代码写了段调用调用PLSQL并执行相关语句的片段。运行成功搞定。。代码中对plsql的路径和用于运行的语句(从doc中复制的呵呵)DOC文件路径进行了判断如果不正确将提示修改路径一直到路径核对正确为止如果两个路径都正确则直接call dosub().本来想通过字段赋值再sendkeys到plsql中指定的语句但是后来发现语句中有特殊字符读到plsql中的时候很慢而且有乱码所以后来想用vbs操作了下word直接从word中复制语句再在plsql中粘贴了.(从plsql中打开我试过了没有句柄不行ctrlo不执行。)VBS代码----------------------------定义变量-------------------------------------------Dim oApp,oDoc,fso,exepath,docpath,inputexestr,inputdocstr,inputexestr2,inputdocstr2,confirmexepath,confirmdocpath,exefile,docfileexepath C:\Worksoft\plsql\PlSqlDev.exedocpath C:\StudyInfo\Study\VBS\ReadyData.doc----------------------------创建系统对象------------------------------------Set WshellCreateObject(Wscript.Shell)set fsoCreateObject(Scripting.FileSystemObject)----------------------------判断plsql路径和doc文件路径是否存在----------------------Call maincheck()Sub checkexeway()inputexestr InputBox(请确认或输入您的plsql程序路径:vbnewline如果此路径正确请点击OK!,PLSQL路径确认,exepath)inputexestr2 fso.FileExists(inputexestr)If inputexestr2 and inputexestr2 True Thenconfirmexepath inputexestrcall checkdocway()elsecall checkexeway()End IfEnd SubSub checkdocway()inputdocstr InputBox(请确认或输入您的DOC文件路径:,DOC文件路径确认,docpath)inputdocstr2 fso.FileExists(inputdocstr)If inputdocstr2 and inputdocstr2 True Thenconfirmdocpath inputdocstrcall Dosub()elsecall checkdocway()End IfEnd SubSub maincheck()exefile fso.FileExists(exepath)docfile fso.FileExists(docpath)If exefile true and docfile true Thenconfirmexepath exepathconfirmdocpath docpathcall Dosub()elsecall checkexeway()End Ifend sub-------------------------------------------调用plsql并运行语句过程--------------------------------------------Sub Dosub()msgbox confirmexepathmsgbox confirmdocpathSet App CreateObject(Word.Application)oApp.visible trueSet Doc oApp.Documents.Open (confirmdocpath)Wshell.AppActivate ReadyData.doc - Microsoft WordoApp.selection.WholeStoryoApp.selection.copyoDoc.closeoApp.quitWshell.SendKeys {Left}Wshell.SendKeys {Enter}wait 5wait 2set execWshell.Exec(confirmexepath)wait 2这里直接输入密码test因为plsql默认了用户名不用输入没有默认就需要前面再加 个sendkeys了Wshell.SendKeys testwait 1Wshell.SendKeys {TAB}这里输入服务器名称.要确保你的oracal的tnsname里面有这个服务器名.Wshell.SendKeys cis170wait 2Wshell.SendKeys {ENTER}wait 4把刚才从word复制的内容粘贴到plsqlWshell.SendKeys ^vwait 2运行语句快捷键f8Wshell.SendKeys {F8}wait 5提交语句commit快捷键f8Wshell.SendKeys {F10}wait 2Wshell.SendKeys %{F4}wait 2Wshell.SendKeys {Right}Wshell.SendKeys {Enter}End Sub