以
QTP附带的订票网站sample为例,edit控件username鼠标右键,点击paste(第4个菜单项)
cur_replay_type = Setting.WebPackage("ReplayType")
Setting.WebPackage("ReplayType") = 2
Browser("
Browser").Page("Welcome:
Mercury Tours").WebEdit("userName").Click 5,4, micRightBtn
Setting.WebPackage("ReplayType") = cur_replay_type
index=4
Set WshShell = CreateObject("Wscrīpt.Shell")
For i = 1 To index
WshShell.sendKeys "{DOWN}"
Next
WshShell.sendKeys "{ENTER}"
Set WshShell = nothing
'此函数用于加载指定
Test所有的插件,若要运行Test可自己加个qtApp.Test.Run
Function Load_Addins(testPath)
Dim qtApp 'As QuickTest.Application
Dim blnNeedChangeAddins
Dim arrTestAddins
Set qtApp = CreateObject("QuickTest.Application")
arrTestAddins = qtApp.GetAssociatedAddinsForTest(testPath)
blnNeedChangeAddins = False
For Each testAddin In arrTestAddins
If qtApp.Addins(testAddin).Status <> "Active" Then
blnNeedChangeAddins = True
Exit For
End If
Next
If qtApp.Launched And blnNeedChangeAddins Then
qtApp.Quit
End If
If blnNeedChangeAddins Then
Dim blnActivateOK
blnActivateOK = qtApp.SetActiveAddins(arrTestAddins, errorDescrīption)
If Not blnActivateOK Then
Call ErrorLog(errorDescrīption) '这里是调用自己的日志函数,可替换为自己的或注释掉
Wscrīpt.Quit
End If
End If
If Not qtApp.Launched Then
qtApp.Launch
End If
qtApp.Visible = True
qtApp.Open testPath
'可在此加入qtApp.Test.Run来运行Test
Set qtApp = Nothing
End Function