TA的每日心情 | 郁闷 2018-11-15 14:58 |
---|
签到天数: 2 天 连续签到: 2 天 [LV.1]测试小兵
|
请教一个问题,为什么下面的代码运行这么慢
Function setObj(obj,operator,value)
Dim errMsg,succMsg
If Not obj.Exist Then
errMsg = obj.ToString & " 不存在"
'errMsg = "对象不存在"
Log "STEP", errMsg
setObj = False
Exit Function
End If
Select Case operator
Case 1
'执行set方法
succMsg = obj.ToString & " set " & value
obj.Set value
Log "STEP", succMsg
Case 2
'执行Click方法
succMsg = obj.ToString & " 执行方法Click "
obj.Click
Log "STEP", succMsg
Case 3
'执行Object.innerText属性
succMsg = obj.ToString & " Object.innerText set " & value
obj.Object.innerText = value
Log "STEP", succMsg
Case 4
'判断item的值是否在weblist中
If Not checkWebList(obj,value) Then
errMsg = obj.ToString & " 中item不存在" & value
setObj = False
Log "STEP", errMsg
Exit Function
End If
succMsg = obj.ToString & " Select " & value
obj.Select value
Log "STEP", succMsg
Case 5
'判断item值是否正确
'If CInt(value)>CInt(obj.GetROProperty("items count")) Then
' errMsg = obj.ToString & " 中item不存在" & value
' setObj = False
' Log "STEP", errMsg
' Exit Function
'End If
succMsg = obj.ToString & " Select " & value
obj.Select value
Log "STEP", succMsg
Case 6
'执行验证码set方法
succMsg = obj.ToString & " set " & value
obj.Click
obj.Set value
Log "STEP", succMsg
End Select
setObj = True
End Function
Function login(email,password)
Log "STEP","in Function login()"
'关闭所有浏览器窗口
closeBrowser()
'创建IE
OpenWeb("http://test/login.html")
If Not setObj(Browser("test").Page("test").WebEdit("email"),1,email) _
And setObj(Browser("test").Page("test").WebEdit("password"),1,password) Then
' Or setObj(Browser("test").Page("test").WebEdit("验证码"),1,code)
Log "STEP","找不到登录入口"
Exit Function
End If
If Not setObj(Browser("tett").Page("test").WebButton("登录"),2,"") Then
Log "STEP","找不到登录按钮"
Exit Function
End If
If isExist(Browser("test").Page("test").Link("退出")) Then
login=true
End If
End Function |
|