gpt4 book ai didi

javascript - Powershell 选择 ID 元素并从网页中单击

转载 作者:行者123 更新时间:2023-11-28 05:30:58 26 4
gpt4 key购买 nike

我希望在 powershell 中打开并单击网页中的按钮。

我选择的元素是:

<span class="x-btn-inner x-btn-inner-center" id="BtnExportCSV" unselectable="on">Export Dashboard as CSV File</span>

在 Web 控制台中,如果我运行以下代码,按钮将成功点击:

document.getElementById("BtnExportCSV").click();

我在powershell中运行的脚本如下。

# open the specified web site and commit the key
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("http://wegpage.com/")
$ie.visible = $true
while($ie.busy) {sleep 1}

$doc = $ie.document

# commit the button
$commit = $doc.getElementById("BtnExportCSV")
if ($commit) { $commit.click() }

网页加载成功,但按钮未单击。相反,会产生错误:

You cannot call a method on a null-valued expression.
$commit = $doc.getElementByID("BtnExportCSV")

如何解决此错误?非常感谢任何帮助!

最佳答案

小写 getElementByID("BtnExportCSV") 中的“d”

$commit = $doc.getElementById("BtnExportCSV")

关于javascript - Powershell 选择 ID 元素并从网页中单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39708059/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com