问题描述
我已成功使用此站点上的Web自动化脚本: heise网站自动化
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.
e-plus网站的重要组成部分:
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>
Powershell脚本的一部分:
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()
}
}
getElementById适用于ie8,但现在我已更新到ie9,并且它不再起作用.
the getElementById worked for ie8 but now I have updated to ie9 and it is not working anymore.
错误消息:
+ $ie.Document.getElementById <<<< ("IDToken1OL").value = $user
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
参数计数错误.
我所能找到的只是一个提示,即ie9中的getElementById已更改.
all I was able to find was a hint, that in ie9 getElementById changed.
有人可以帮忙吗?
谢谢大卫
推荐答案
仅自动化一个具体站点(并且脚本不是通用站点或任何站点)时,您可以尝试在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.
这篇关于Powershell,即ie9和getElementById的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!