|
' 比如获取某个输入框显示的内容,最后字符串是随机值,需要保留随机值,对其它数值进行任意修改组合:普通呼叫qtp_admin_140610084507
Dim Run_name,MyArray,Msg
'获取当前WebEdit中的value属性值
Run_name = Browser("XXXX").Page("XXXX").WebEdit("XXXX").GetROProperty("value")
'对获取值通过Split进行拆分,以_分隔
MyArray = Split(Run_name,"_",-1,1)
' MyArray(0) contains "普通呼叫qtp".
' MyArray(1) contains "admin".
' MyArray(2) contains "140610084507".
'去掉" _ "
Msg = MyArray(0) & " " & MyArray(1) & " " & MyArray(2)
'灵活组合使用
Msg = Msg & " " & MyArray(2)
’组合回去再加个_qtp
'Msg = MyArray(0) & "_" & MyArray(1) & "_" & MyArray(2) & "_" & MyArray(2) & "_qtp"
'在变量值后加内容也可以直接取
'Msg = Run_name & "_qtp"
’把组合好的值传回去
Browser("XXXX").Page("XXXX").WebEdit("XXX").Set Msg
'打印获取的数值
MsgBox Msg |
|