自动化测试过程中难免会碰到对对象的右键操作,普通录制是无法录制成功的,在脚本里面可以设置回放模式为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