下面是我一直在处理的自动化脚本的开始。该脚本打开 IE,转到 URL 并输入登录凭据。然后我需要检查是否加载了图像(“/codaprod/images/portal.jpg”)......我真的不太了解,我主要从这里和那里挑选一些位。该脚本工作正常,直到我将以下代码添加到末尾。
<script type="text/vbscript">
sub loadImage()
msgbox "Image is loaded"
end sub
</script>
<img src="/codaprod/images/portal.jpg" onload="loadImage">
这段代码有问题还是我在原始代码中遗漏了什么?
下面是我使用的完整 VBScript。
strURL="https://WEBADDRESS.com/codaprod/servlet/HTMLCompiler?app=com.coda.common.esi.framework.apps.Logon"
strUser="USERNAME"
strPass="PASSWORD"
Set oIE = WScript.CreateObject("InternetExplorer.Application","IE_")
Timeout=20 'seconds
oIE.visible=1 : BeginTimer = Timer
oIE.Navigate strURL
i=0 : bElementsLoaded=false
Set CODA_Element_1 = Nothing
Do While (oIE.ReadyState<>4 Or Not(bElementsLoaded)) And i < Timeout
WScript.Sleep(1000):i=i+1
On Error Resume Next
Set CODA_Element_1 = oIE.Document.getElementById("user")
Set CODA_Element_2 = oIE.Document.getElementById("password")
Set CODA_Element_3 = oIE.Document.getElementById("next")
If (Not(CODA_Element_1 is Nothing)) Then
bElementsLoaded=true
End If
On Error Goto 0
Loop
CODA_Element_1.value=strUser
CODA_Element_2.value=strPass
CODA_Element_3.Click()
wscript.sleep 3000
<script type="text/vbscript">
sub loadImage()
msgbox "Image is loaded"
end sub
</script>
<img src="/codaprod/images/portal.jpg" onload="loadImage">
感谢您的阅读,请随时指出您的任何提示和技巧。再次感谢