正在努力研究以下内容。internetexplorer.application document.getElementByID返回为null/Powershell
查看HTML摘录,ID存在但它一直返回空表达式。不幸的是,我不能在网站上提供任何更多细节......任何明显的我做错了什么?
--- HTML摘录----
<input name="ctl00$mainCopy$LoginView$LoginControl$UserName" type="text" id="ctl00_mainCopy_LoginView_LoginControl_UserName" tabindex="1" class="txtBox" onchange="document.getElementById('ctl00_mainCopy_LoginView_LoginControl_PasswordResetLink').disabled
= false;" style="width:150px;" />
---脚本---
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate("excluded for security")
$ie.document.getElementByID("ctl00_mainCopy_LoginView_LoginControl_UserName").Value= "excluded for security"
---- ----错误
你不能调用一个空值表达式的方法。 在线:1 char:1 + $ ie.document.getElementByID(“ctl00_mainCopy_LoginView_LoginControl_UserName”)。Va ... + ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ + CategoryInfo:InvalidOperation:(:) [],的RuntimeException + FullyQualifiedErrorId:InvokeMethodOnNull
对我来说''ie.Busy'只能作为一个属性,不能像代码片段中的方法调用一样。 – esel 2017-05-16 09:19:10
你是对的,自从我写出这个答案以来它可能已经发生了变化 – 2017-05-16 10:15:33