QTP常用程序和函數(shù)_第1頁(yè)
QTP常用程序和函數(shù)_第2頁(yè)
QTP常用程序和函數(shù)_第3頁(yè)
QTP常用程序和函數(shù)_第4頁(yè)
QTP常用程序和函數(shù)_第5頁(yè)
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、qtp 常用程序和函數(shù)瘋狂代碼 http:/ ?:http:/ 1. 創(chuàng)建個(gè) vbs文件:testvbs.vbs 內(nèi)容如下 : # subcloseweb 此處可以用到描述性編程把先期打開(kāi)ie窗口全關(guān)閉 dimwinie,ie,i,m setwinie=descr ption.create winie(regexpwndtitle).value=microsoftinternetexplorer所有頁(yè)面 regexpwndtitle屬性值都是microsoftinternetexplorer也可以用其他屬性 setie=desktop.childobjects(winie) m=ie.coun

2、t fori=1tom ie(i-1).close0為最后打開(kāi)個(gè) , 可關(guān)閉打開(kāi)幾個(gè) , 循環(huán)改成 fori=1tom next endsub # functiontestvbs(format) msgbox參數(shù)是 &format endfunction # # 往文件里面寫(xiě)內(nèi)容 第個(gè)參數(shù)文件路徑 第 2 個(gè)參數(shù) : 寫(xiě)入內(nèi)容 第 3 個(gè)參數(shù) : 寫(xiě)入格式 (appending/writing) seealsofileobject subwrite2file(filepath,content,style) dimfso,f dimstl ifu(style)=appendingthen

3、 stl=8 u(style)=writingthen stl=2 reporter.reportevent1,參數(shù),writing:withpage exitsub end endif setfso=createobject(scrpting.fileobject) setf=fso.opentextfile(filepath,stl,true) content=寫(xiě)入第行內(nèi)容 f.writeline(content) f.close setf=nothing setfso=nothing endsub # # # 連接數(shù)據(jù)庫(kù)子 第個(gè)參數(shù) : 根據(jù)數(shù)據(jù)庫(kù)類(lèi)型設(shè)計(jì)連接串( 參見(jiàn)udl 文件) 第

4、 2 個(gè)參數(shù) : 連接數(shù)據(jù)庫(kù)的后進(jìn)行查詢(xún)相應(yīng)語(yǔ)句 第 3 個(gè)參數(shù) : 查詢(xún)記錄返回到 res subopendb(conn,sql,res) setcnn=createobject(adodb.connection) cnn.openconn setres=createobject(adodb.record) res.opensql,cnn,1,1 endsub # # # 關(guān)閉數(shù)據(jù)庫(kù)連接 subclosedb setres=nothing setcnn=nothing endsub # 2.qtp 導(dǎo)入這個(gè) testvbs.vbs 文件: 菜單:test-setting-resource 在

5、“associatedlibraryfiles”添加入該文件 這里建議可以使用相對(duì)路徑如.testvbs.vbs 3. 測(cè)試封裝子 : 用“runfromsteps”運(yùn)行模式 ( 專(zhuān)家視圖右鍵第 4 個(gè)菜單項(xiàng)腳本從光標(biāo)處運(yùn)行) 在qtp 中添加測(cè)試代碼 : closeweb 實(shí)現(xiàn)關(guān)閉當(dāng)前所有 ie窗口 stop 外部 write2file write2filec:file.txt,writhingaline,writing write2filec:file.txt,appendingaline,appending write2filec:file.txt,appendingaline,appe

6、nding!參數(shù)不正確 page write2file.vbsfile.txt,appendingaline,appending stop 設(shè)置連接數(shù)據(jù)庫(kù)所需要值包括: conn: 數(shù)據(jù)庫(kù)連接串 sql: 查詢(xún)sql 語(yǔ)句 res: 查詢(xún)返回記錄 dimconn,sql,res conn=provider=msdasql.1;persistsecurityinfo=false;datasource=qt_flight32 sql=select*fromorders setres=nothing 外部子 opendb 進(jìn)行連接數(shù)據(jù)庫(kù) opendbconn,sql,res msgboxres.re

7、cordcount& 行,&res.fields.count&列 res.movefirst res.movenext 沒(méi)有它話記錄就成了死循環(huán) reporter.reportevent2,測(cè)試連接數(shù)據(jù)庫(kù) ,數(shù)據(jù)庫(kù)獲取數(shù)據(jù) :&res.fields(0) rowcount=res.recordcount columncount=res.fields.count whilenotres.eof record= fori=0tocolumncount-1 record=record&:&res.fields(i) next record=mid(record,2) repo

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論