|
在QTP脚本中,ACtion1调用ACtion2,ACtion2脚本的功能就是打开指定文件另存为ANSI格式,问题就出现在脚本执行在执行到点击记事本“另存为”菜单时,“共用对话框错误”就出现了,不知如何解决此问题,望高人相助!
ACtion2脚本如下(单独运行不会出现此问题):
Dim fileName ,text , filePath
' filePath = Parameter("FilePath")
filePath = "G:\Program Files\HP\QuickTest Professional\Tests\Test2\Test2.usr"
SystemUtil.Run "notepad.exe" , filePath
fileName =Right ( filePath , len( filePath) - InStrRev( filePath, "\",-1,1) )
'记事本.usr - 记事本
text= fileName&" - 记事本"
Dim dsc , dscButton
Set dsc=Description.Create()
dsc("text").value = text
Window(dsc).WinMenu("menuobjtype:=2").Select "文件(F);另存为(A)..."
Dim dscDialog , dscComboBox , ComboBoxCount , ComboBoxCollection , CodeType
Set dscDialog =Description.Create()
dscDialog("text" ).value = "另存为"
Set dscComboBox=Description.Create()
dscComboBox("nativeclass").value = "ComboBox"
'set ComboBoxCollection =Window(dsc).Dialog( dscDialog).ChildObjects( dscComboBox)
'ComboBoxCount= ComboBoxCollection.count
'set CodeType=ComboBoxCollection( ComboBoxCount -1)
Window(dsc).Dialog( dscDialog).WinComboBox("Class Name:=WinComboBox","Index:=3").Select "ANSI"
set dscButton =Description.Create()
dscButton ("nativeclass").value = "Button" '"text:=保存(&S)","nativeclass:=Button","Index:=0"
dscButton ("Index").value = "0"
Window(dsc).Dialog( dscDialog).WinButton( dscButton ).Click
Window(dsc).Dialog( dscDialog).Dialog( dscDialog).WinButton( dscButton ).Click
Window(dsc).Close |
|