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

下載本文檔

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

文檔簡介

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

2、t fori=1tom ie(i-1).close0為最后打開個(gè) , 可關(guān)閉打開幾個(gè) , 循環(huán)改成 fori=1tom next endsub # functiontestvbs(format) msgbox參數(shù)是 &format endfunction # # 往文件里面寫內(nèi)容 第個(gè)參數(shù)文件路徑 第 2 個(gè)參數(shù) : 寫入內(nèi)容 第 3 個(gè)參數(shù) : 寫入格式 (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=寫入第行內(nèi)容 f.writeline(content) f.close setf=nothing setfso=nothing endsub # # # 連接數(shù)據(jù)庫子 第個(gè)參數(shù) : 根據(jù)數(shù)據(jù)庫類型設(shè)計(jì)連接串( 參見udl 文件) 第

4、 2 個(gè)參數(shù) : 連接數(shù)據(jù)庫的后進(jìn)行查詢相應(yīng)語句 第 3 個(gè)參數(shù) : 查詢記錄返回到 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ù)庫連接 subclosedb setres=nothing setcnn=nothing endsub # 2.qtp 導(dǎo)入這個(gè) testvbs.vbs 文件: 菜單:test-setting-resource 在

5、“associatedlibraryfiles”添加入該文件 這里建議可以使用相對路徑如.testvbs.vbs 3. 測試封裝子 : 用“runfromsteps”運(yùn)行模式 ( 專家視圖右鍵第 4 個(gè)菜單項(xiàng)腳本從光標(biāo)處運(yùn)行) 在qtp 中添加測試代碼 : 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ù)庫所需要值包括: conn: 數(shù)據(jù)庫連接串 sql: 查詢sql 語句 res: 查詢返回記錄 dimconn,sql,res conn=provider=msdasql.1;persistsecurityinfo=false;datasource=qt_flight32 sql=select*fromorders setres=nothing 外部子 opendb 進(jìn)行連接數(shù)據(jù)庫 opendbconn,sql,res msgboxres.re

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

最新文檔

評論

0/150

提交評論