转:QTp 描述性语言Diaglog的识别

上一篇 / 下一篇  2011-04-27 18:49:20 / 个人分类:QTP

  • zk818
  • (zk818)
  • 等 级:
  • 结帖率:
楼主发表于:2011-04-18 11:25:49
比如图片如果用户名输入错误的话。弹出一个对话框,请输入用户名,请问如何获取这个文本框上的文本文字?
回复次数:1
#1楼 得分:0回复于:2011-04-19 08:31:54
dim vResult="用户名输入错误,请重新输入" '--预期结果的值

'--判断实际结果与预期结果的值是否一致
If Instr(mBox_Message(),vResult) > 0 Then
  elog.Verfication "0",vResult
  Actualv = "成功信息>>" & vResult & ">>执行通过"
ImageName = ""
  mBox_Operate("确定")
  else
end if


' 取得弹出对话框中信息的值的方法
Function mBox_Message()
  Dim ms
  Set mDes = Description.Create()
  mDes("text").value = ".*Internet Explorer"
  mDes("nativeclass").value = "#.*"
  Set stc = Browser("title:=.*").Dialog(mDes).Static("nativeclass:=Static","window id:=65535")
  ms = stc.GetROProperty("text")
  Set mDes = Nothing
  Set stc = Nothing
  mBox_Message = ms
End Function


' 操作弹出对话框的方法
Function mBox_Operate(operate)
  Set mDes = Description.Create()
  mDes("text").value = ".*Internet Explorer"
  mDes("nativeclass").value = "#.*"
  Browser("title:=.*").Dialog(mDes).WinButton("text:="&cstr(operate)).Click
  Set mDes = Nothing
End Function

比如图片如果用户名输入错误的话。弹出一个对话框,请输入用户名,请问如何获取这个文本框上的文本文字?
 
回答:
dim vResult="用户名输入错误,请重新输入" '--预期结果的值

'--判断实际结果与预期结果的值是否一致
If Instr(mBox_Message(),vResult) > 0 Then
  elog.Verfication "0",vResult
  Actualv = "成功信息>>" & vResult & ">>执行通过"
ImageName = ""
  mBox_Operate("确定")
  else
end if


' 取得弹出对话框中信息的值的方法
Function mBox_Message()
  Dim ms
  Set mDes = Description.Create()
  mDes("text").value = ".*Internet Explorer"
  mDes("nativeclass").value = "#.*"
  Set stc = Browser("title:=.*").Dialog(mDes).Static("nativeclass:=Static","window id:=65535")
  ms = stc.GetROProperty("text")
  Set mDes = Nothing
  Set stc = Nothing
  mBox_Message = ms
End Function


' 操作弹出对话框的方法
Function mBox_Operate(operate)
  Set mDes = Description.Create()
  mDes("text").value = ".*Internet Explorer"
  mDes("nativeclass").value = "#.*"
  Browser("title:=.*").Dialog(mDes).WinButton("text:="&cstr(operate)).Click
  Set mDes = Nothing
End Function
 

TAG:

 

评分:0

我来说两句

Open Toolbar