【发布时间】:2020-05-17 21:29:04
【问题描述】:
我正在尝试自动化网页。
我能够登录并点击页面。 单击新页面后,我需要在其中输入“名称”,但它无法正常工作:Microsoft VBScript 运行时错误'800a01a8' Object required: 'objIE.document.getElementById(..)
下面是我正在使用的代码
struser = "user"
strPass = "pswd"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "http://myurl"
While objIE.Busy = True
WScript.Sleep 100
Wend
While objIE.ReadyState <> 4
WScript.Sleep 100
Wend
objIE.Document.all.User.value = struser
objIE.Document.all.Password.value = strPass
objIE.Document.Forms(0).Submit()
While objIE.Busy = True
WScript.Sleep 100
Wend
While objIE.ReadyState <> 4
WScript.Sleep 100
Wend
objIE.Document.all.drop_mainmenu.click()
objIE.Document.all.BOX.value = "12"
objIE.Document.all.Button.Click()
While objIE.Busy = True
WScript.Sleep 100
Wend
While objIE.ReadyState <> 4
WScript.Sleep 100
Wend
'dim srch
'objIE.Document.getElementsByName("0_58").value = "Long"
'srch.value = "Long"
set el = objIE.document.getElementById("C0_58")
'If el.value is nothing Then
set el.value = "Long"
'End If
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^%L"
below is the snippet of source code for that field.
enter code here<input name="0_58" tabindex="6" title="Alpha Name" class="textfield" id="C0_58" style="width: 218px;
vertical-align: top; cursor: auto;" onmouseover="updateHelpCursor('',this)" onhelp="hp('0_58')"
onfocus="FCHandler.onFocus(this,'',false)" onblur="FCHandler.onExit(this,false,'',false)"
type="text" maxlength="40" value=" " htmlpostflag="false">
enter code here
【问题讨论】:
-
这行得通吗?? set el = objIE.document.getElementById("C0_58")..... 用双引号将 ID 括起来
-
与 set el = objIE.document.getElementById("C0_58") 相同的错误
-
忘记更新了,这个字段在一个 iframe 里面,里面有多个表和 span。
-
那么可能是objIE对象有问题。 'objIE .Visible = True' 语句是否出现错误。尝试将它放在 set el = objIE.document.getElementById(C0_58)...你能把这个objIE的代码贴出来吗?
-
struser = "user" strPass = "pswd" 设置 objIE = CreateObject("InternetExplorer.Application") objIE.Visible = True objIE.Navigate "myurl" 而 objIE.Busy = True WScript。 Sleep 100 Wend While objIE.ReadyState 4 WScript.Sleep 100 Wend
标签: vbscript