Powershell,ie9 和 getElementById

标签 powershell internet-explorer-9 getelementbyid

我成功地使用了此站点的 Web 自动化脚本:heise web automation

我知道它是德语的,但也许有人可以提供帮助。

易加网站的重要部分:

    <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 发生了变化。

有人可以帮忙吗?

谢谢,大卫

最佳答案

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Q_27920160.html ——

引:
“我应该使用成员调用:

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("about:blank")
$doc = $ie.Document

$element = [System.__ComObject].InvokeMember(“getElementById”,[System.Reflection.BindingFlags]::InvokeMethod, $null, $doc, $id)

对于 getElementsByTagName:
$elements = @([System.__ComObject].InvokeMember(“getElementsByTagName”,[System.Reflection.BindingFlags]::InvokeMethod, $null, $doc, $tagname))

关于Powershell,ie9 和 getElementById,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6065359/

相关文章:

Powershell 启动进程 : This command cannot be executed due to the error: Access is denied

powershell 解析连接目标路径

powershell - 远程获取默认打印机

css - 如何防止在 jqGrid 中的 Internet Explorer 9 中每次单击时表单高度增加

javascript - 使用 Javascript 将 HTML 中的段落替换为新段落

javascript - document.getElementById 破坏了代码

javascript - 而不是提示从石头、剪刀、布等游戏的图像中进行选择

powershell - powershell 中 Get-ChildItem 命令的默认结果集顺序是什么?

css - 显示部分文本的下拉列表

html - IE9在页面底部呈现白线