QTP 實現右鍵操作菜單

自動化測試過程中難免會碰到對對象的右鍵操作,普通錄製是無法錄製成功的,在腳本里面可以設置回放模式爲2,即模擬鼠標操作。

具體代碼如下:

            Dim ip_folderName ,arr_ip_folderName 

        ip_folderName = "其他文件夾||已刪除"'

        arr_ip_folderName = Split(ip_folderName,"||",-1,1)
         Set wshShell = CreateObject("WScript.Shell")
         Setting.WebPackage("ReplayType") = 2  'set reply mode

          For i = 0 To ubound(arr_ip_folderName)
             If arr_ip_folderName(i) = "收件箱" Then
                   currentPage.WebElement("innertext:="&arr_ip_folderName(i)&"(.)*","index:=2").Click ,,micRightBtn
              Else
                 currentPage.WebElement("text:="&arr_ip_folderName(i)&"(.)*","index:=0").Click ,,micRightBtn
             End If    
                    wshShell.SendKeys "{DOWN}" '鍵盤向下的箭頭
                    wshShell.SendKeys "{ENTER}" '回車鍵
             wait 3
         Next

        Setting.WebPackage("ReplayType") = 1 'reset reply mode



發佈了39 篇原創文章 · 獲贊 63 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章