Powershell、ie9 和 getElementById
我成功地使用此网站的 Web 自动化脚本: heise Web 自动化
我知道它是德语的,但也许有人可以帮忙。
e-plus网站的重要部分:
<tr>
<td class="td1">Benutzername:</td>
<td class="space"><img src="/img/c.gif" alt="" /></td>
<td class="td2"><input type="text" id="IDToken1OL" name="IDToken1" onfocus="setToken(this)" onblur="getToken(this)" value="Benutzername" /></td>
</tr>
<tr>
<td class="td1">Passwort:</td>
<td class="space"><img src="/img/c.gif" alt="" /></td>
<td class="td2"><input type="password" id="IDToken2OL" name="IDToken2" onfocus="setToken(this)" onblur="getToken(this)" value="" class="passwortFake" /></td>
</tr>
Powershell脚本部分:
$script:ie = New-Object -comobject InternetExplorer.Application
$ie.visible = $false
$ie.silent = $true
#
$ie.Navigate("https://www.eplus.de/login/login.asp")
LadenWarten(1)
#
$ie.Document.getElementById("IDToken1OL").value = $user
$ie.Document.getElementById("IDToken2OL").value = $passwort
$ie.Document.getElementsByTagName("a") | foreach {
if ($_.href -eq "javascript:SSO_Submit()") {
$_.Click()
}
}
getElementById适用于ie8,但现在我已经更新到ie9,它不再工作了。
错误消息:
+ $ie.Document.getElementById <<<< ("IDToken1OL").value = $user
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
参数计数错误。
我所能找到的只是一个提示,即在 ie9 中 getElementById 发生了变化。
有人可以帮忙吗?
谢谢,大卫
I use successfully a script for web automation from this site: heise web automation
I know it is in german, but perhaps someone can help.
The important part of the e-plus website:
<tr>
<td class="td1">Benutzername:</td>
<td class="space"><img src="/img/c.gif" alt="" /></td>
<td class="td2"><input type="text" id="IDToken1OL" name="IDToken1" onfocus="setToken(this)" onblur="getToken(this)" value="Benutzername" /></td>
</tr>
<tr>
<td class="td1">Passwort:</td>
<td class="space"><img src="/img/c.gif" alt="" /></td>
<td class="td2"><input type="password" id="IDToken2OL" name="IDToken2" onfocus="setToken(this)" onblur="getToken(this)" value="" class="passwortFake" /></td>
</tr>
the part of the Powershell script:
$script:ie = New-Object -comobject InternetExplorer.Application
$ie.visible = $false
$ie.silent = $true
#
$ie.Navigate("https://www.eplus.de/login/login.asp")
LadenWarten(1)
#
$ie.Document.getElementById("IDToken1OL").value = $user
$ie.Document.getElementById("IDToken2OL").value = $passwort
$ie.Document.getElementsByTagName("a") | foreach {
if ($_.href -eq "javascript:SSO_Submit()") {
$_.Click()
}
}
the getElementById worked for ie8 but now I have updated to ie9 and it is not working anymore.
the errormessage:
+ $ie.Document.getElementById <<<< ("IDToken1OL").value = $user
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
the count of the arguments is wrong.
all I was able to find was a hint, that in ie9 getElementById changed.
can anybody help?
Thanks, David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅http://www.experts-exchange.com/Web_Development/Web_Languages-标准/Q_27920160.html——
引用:
“我应该使用成员调用:
以及 getElementsByTagName:
”
See http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Q_27920160.html --
Quoted:
"I should've used member invocation:
and for getElementsByTagName:
"
当仅自动化一个具体站点(并且脚本不是通用的或任何站点)时,您可以尝试在 IE 设置中设置兼容性视图(工具 -> 兼容性视图设置)。浏览网站时,IE 应切换到 IE8 视图。
When automating only one concrete site (and the script is not generic or any site) you can try to set compatibility view in IE settings (Tools -> Compatibility View settings). IE should switch to IE8 view when browsing the site.
使用查询选择器的示例:
Example of using querySelector: