QTP tips

發表于:2011-10-09來源:未知作者:領測軟件測試網采編點擊數: 標簽:qtp
1、Object Spy的Tips Hold the CTRL key to change the window focus or perform other mouse operations 2、QTP為什么無法單步調試? 安裝Microsoft Script Debuger即可

  1、Object Spy的Tips

  Hold the CTRL key to change the window focus or perform other mouse operations

  2、QTP為什么無法單步調試?

  安裝Microsoft Script Debuger即可

  3、QTP如何訪問Oracle數據庫?

  Dim rs,sq,pkey

  set conn=createobject("adodb.connection")

  set rs=createobject("adodb.recordset")

  ' 需要安裝Oracle客戶端

  conn.open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=scott;Data Source=orcl;Password=orcl;Extended Properties=;Host=192.168.1.188;Port=1521;Service Name=orcl;"

  sql="SELECT * FROM TAB"

  rs.open sql,conn

  rs.MoveFirst

  Do While rs.Eof<>true

  Msgbox rs.Fields(0)

  rs.MoveNext

  Loop

  rs.close

  set rs=nothing

  conn.close

  set conn=nothing

  4、如何全選所有WebCheckBox對象?

  Dim oWebChkDesc

  Set oWebChkDesc = Description.Create

  oWebChkDesc("micclass").value = "WebCheckBox"

  oWebChkDesc("html tag").Value = "INPUT"

  ' 獲取所有匹配描述的對象

  Dim allCheck, oCheckBox

  Set allCheck = Browser("Web Tours").Page("Web Tours").ChildObjects(oWebChkDesc)

  For i = 0 to allCheck.Count - 1

  Set oCheckBox = allCheck(i)

  oCheckBox.Set "ON"

  Next

  5、QTP9.2錄制腳本問題:運行QTP,點擊錄制鈕進行腳本錄制,但是IE瀏覽器打開后幾秒鐘,又自動關閉了,不知道為什么?

  QTP9.2支持的IE瀏覽器版本:

  Microsoft Internet Explorer 6.0 Service Pack 1

  Microsoft Internet Explorer 7.0

  6、Action之間無法傳遞數組

  用全局的Dictionary對象來存儲數據,這樣可以在多個Action之間共用數據

  參考:

  http://blog.csdn.net/Testing_is_believing/archive/2010/01/08/5161955.aspx

  http://blog.csdn.net/Testing_is_believing/archive/2008/06/09/2528094.aspx

  也可以這樣:

  建一個vbs文件,定義變量,在Setting—>Resources導入這個VBS文件

  在主Action里面 給變量賦值

  在子Action中調用這個變量

  這個變量的內存相當于共享

  7、QTP腳本編輯器中可以修改Tab鍵跳轉的格數嗎?

  編輯腳本時,總感覺Tab一次,移動的格數太少

  Tools -> View Options

  8、如何在VBScript中調用QTP腳本

  現在有一個用QTP錄制好的腳本,但是想用VBS來調用,如何調用?

  Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

  Dim qtTest 'As QuickTest.Test ' Declare a Test object variable

  Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable

  Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

  qtApp.Launch ' Start QuickTest

  qtApp.Visible = True ' Make the QuickTest application visible

  ' Set QuickTest run options

  qtApp.Options.Run.ImageCaptureForTestResults = "OnError"

  qtApp.Options.Run.RunMode = "Fast"

  qtApp.Options.Run.ViewResults = False

  qtApp.Open "C:\Tests\Test1", True ' Open the test in read-only mode

  ' set run settings for the test

  Set qtTest = qtApp.Test

  qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4

  qtTest.Settings.Run.StartIteration = 2

  qtTest.Settings.Run.EndIteration = 4

  qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

  Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

  qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location

  qtTest.Run qtResultsOpt ' Run the test

  MsgBox qtTest.LastRunResults.Status ' Check the results of the test run

  qtTest.Close ' Close the test

  Set qtResultsOpt = Nothing ' Release the Run Results Options object

  Set qtTest = Nothing ' Release the Test object

  Set qtApp = Nothing ' Release the Application object

  9、沒安裝QTP打開QTP腳本的方法

  QTP的腳本在每個action的根目錄下的Script.mts文件,用UltraEdit或記事本等工具打開就可以看到。

  10、QTP支持的正則表達式

  使用反斜杠字符 ( \ )

  匹配任意單個字符 ( . )

  匹配列表中的任意單個字符 ( [xy] )

  匹配不在列表中的任意單個字符 ( [^xy] )

  匹配某個范圍內的任意單個字符 ( [x-y] )

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97