當前位置:首頁 » 編程軟體 » qtp腳本

qtp腳本

發布時間: 2022-01-23 19:31:06

A. QTP手寫腳本的步驟是怎樣的呢

錄制和手寫可以配合使用
我一般是先錄制一個簡單的操作,比如登錄,然後打開要測試的頁面,結束錄制
回放檢測有沒有錯誤,
沒有錯誤就開始手工寫腳本增加操作步驟,如果有錯誤就調試腳本解決問題
不是每個腳本都需要用到對象庫,有時適當使用描述性編程更有效率,這時是不需要使用對象庫的
比如
這是應用對象庫的腳本 Browser(「測試頁面」).Page(「測試頁面").WebEdit("測試按鈕").Click
這三個對象都會在對象庫中找到
描述性編程的腳本
Browser(「測試頁面」).Page(「測試頁面").WebEdit("innertext:=測試按鈕").Click
WebEdit對象沒在對象庫中

B. QTP錄了一個腳本、我想讓他重復執行100次、怎麼操作啊

1、如果有需要參數化的數據,將該數據參數化100次即可
2、如果沒有需要參數化的,在腳本的data table中第一列輸入100行數據(任意數據)即可
另:手動在data table中輸入100行數據太麻煩,可以在腳本保存的目錄下找到Default.xls,該文件即為data table表格,修改後保存,再重新打開腳本就可以看到修改後的數據

C. QTP如何寫腳本語言進行對象的雙擊操作

調用滑鼠事件吧: FireEvent("參數")
參數:onclick —單擊 onmousebover—滑鼠停留 ondbclick—雙擊 onfocus—使獲得焦點

例子:
Browser("XX").Page("XX").Link("XX").FireEvent("onclick")

D. QTP的2種腳本調用方法是什麼

QTP的2種腳本調用方法是什麼
我不知道你調用腳本是什麼概念?在QTP中調用外部腳本?還是啟動QTP腳本?
調用外部腳本,你可以採取VBS的程序去調用外部程序,或者你可以寫COM介面,然後再QTP的中調用!
啟動QTP腳本,你可以採取QTP的COM介面通過程序來調用
(3atesing有大量視頻專門介紹QTP的各類實用模式的)
QTP的COM調用可參考:
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Launch QuickTest
qtApp.Visible = True ' Set QuickTest to be visible
' Open a test and get the "Login" action's object repositories collection
qtApp.Open "C:\Tests\Test1", False, False ' Open a test
Set qtRepositories = qtApp.Test.Actions("Login").ObjectRepositories ' Get the object repositories collection object of the "Login" action
' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find("C:\MainApp.tsr") = -1 Then ' If the repository cannot be found in the collection
qtRepositories.Add "C:\MainApp.tsr", 1 ' Add the repository to the collection
End If
' If InnerWnd.tsr is moved down the list - place it back at position 1
If qtRepositories.Count > 1 And qtRepositories.Item(2) = "C:\InnerWnd.tsr" Then ' If there's more than one object repository and InnerWnd.tsr is in position 2
qtRepositories.MoveToPos 1, 2 ' Switch between the first two object repositories
End If
' If Debug.tsr is in the collection - remove it
lngPosition = qtRepositories.Find("C:\Debug.tsr") ' Try finding the Debug.tsr object repository
If lngPosition -1 Then ' If the object repository was found in the collection
qtRepositories.Remove lngPosition ' Remove it
End If
' Set the new object repository configuration as the default for all new actions
qtRepositories.SetAsDefault ' Set object repositories associated with the "Login" action as the default for all new actions
'Save the test and close QuickTest qtApp.Test.Save ' Save the test qtApp.Quit ' Quit QuickTest Set qtRepositories = Nothing ' Release the action's shared repositories collection Set qtApp = Nothing ' Release the Application object

E. qtp測試腳本語言是什麼

QTP是基於VBS腳本語言的,大部分VBS腳本都能在QTP上運行,只是在一些細節上略有不同,比如說VBS上停止用sleep,QTP上用wait。QTP的強大之處在於對程序窗口的操作,有很多針對窗體的屬性、方法,這個是VBS所沒有的。

F. QTP腳本怎麼強化

首先這不是個問題,QTP直接回放錄制的腳本原本就基本相當於重復一次之前的手動操作,正常情況下就是按照原來既定的來走。也就是說你錄的時候手動操作一次,回放的時候又做了一次同樣的操作。

但一般來說我們在開始一次新的測試前,往往需要恢復測試場景,比如恢復測試資料庫等方式來重置測試場景,確保回放時的場景狀態和錄制腳本時是一致的,這樣才能比較好的完成回放過程。

若是希望用不同的數據來進行操作,那麼可以對腳本做些最基本的增強,比如將"名稱"參數化一下,用其它的指定名稱或者隨機字元串進行接下來的操作。

G. 請教 關於QTP的腳本語言

學工具需要從基礎學起,先看書吧,看資料吧

H. 如何自動執行QTP測試腳本,即自動啟動QTP並執行軟體測試過程

使用自帶的batch run,或者查詢qtp aom上面有腳本例子可以自動調用qtp。
Set qtApp = CreateObject("QuickTest.Application")

qtApp.Launch
。。。。

I. 要讓QTP腳本運行完後在次運行

把腳本保存成個a.vbs文件
在QTP腳本的最後面,加一句systemutil.run
路徑+
"a.vbs"
systemutil是QTP的一個內置對象,可以啟動運行application或者windows腳本

J. 如何使用QTP腳本的封裝和調用方法

把QTP腳本封裝起來,使其看起來一目瞭然! 簡單介紹一下方法: '啟動飛機訂票系統 Sub flight() SystemUtil.Run "D:\Program Files\ Mercury Interactive\ QuickTest Professional \samples\flight\app\flight4a.exe","","D:\Program Files\Mercury Interactiv
把QTP腳本封裝起來,使其看起來一目瞭然!
簡單介紹一下方法:

'啟動飛機訂票系統

Sub flight()

SystemUtil.Run "D:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","D:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"

End Sub

'登錄

Sub login()

Dialog("Login").WinEdit("Agent Name:").Set "cff100"

Dialog("Login").WinEdit("Password:").SetSecure ""

Dialog("Login").WinButton("OK").Click

End Sub

'插入訂單

Function insertorder()

Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"

Window("Flight Reservation").WinComboBox("Fly From:").Select "London"

Window("Flight Reservation").WinComboBox("Fly To:").Select "Paris"

Window("Flight Reservation").WinButton("FLIGHT").Click

Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "12538 LON 10:24 AM PAR 12:24 PM AF $162.40" 可以以數值代替如2

Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

Window("Flight Reservation").WinEdit("Name:").Set "cff100"

Window("Flight Reservation").WinRadioButton("Business").Set

Window("Flight Reservation").WinButton("Insert Order").Click

Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", Insert Done..., 10000

End Function

'退出

Sub logout()

Window("Flight Reservation").Close

End Sub

其實就是把腳本按操作分段。然後以過程(SUB.....END SUB)或函數(FUNCTION ....END FUNCTION)進行封裝。

這樣的腳本看上去一目瞭然,易理解也易於管理。

QTP函數過程的調用

以上面的QTP錄制腳本的封裝中的腳本為例:

Call 過程名/函數名

直接調用過程名/函數名

也以飛機訂票系統為例。調用上面封裝的過程/函數:

flight/call flight

login/call login

insertorder/Call insertorder

logout/Call logout

1. 調用SUB/FUNCTION方法是一樣的……除了CALL調用如果有參數則需要使用括弧將參數變數括起來。

2. SUB與FUNCTION的區別:SUB過程是沒有返回值的.但是FUNCTION是可以有返回值的。
轉載,僅供參考,祝你愉快,滿意請採納。

熱點內容
cad解壓錯誤 發布:2024-03-29 15:01:45 瀏覽:78
存儲指令集 發布:2024-03-29 14:39:27 瀏覽:649
資料庫表刪除數據 發布:2024-03-29 14:39:26 瀏覽:367
出c語言整除 發布:2024-03-29 14:28:22 瀏覽:572
芬尼壓縮機 發布:2024-03-29 14:24:11 瀏覽:464
電腦數據實時上傳本地伺服器軟體 發布:2024-03-29 14:07:57 瀏覽:920
尋秦記源碼 發布:2024-03-29 13:56:17 瀏覽:496
linux的備份命令 發布:2024-03-29 13:41:22 瀏覽:383
csgo建議什麼配置 發布:2024-03-29 13:31:44 瀏覽:980
電腦ftp服務如何禁用 發布:2024-03-29 13:24:48 瀏覽:332