gpt4 book ai didi

windows - 方法 "getElementsByClassName"无法识别

转载 作者:可可西里 更新时间:2023-11-01 10:04:48 27 4
gpt4 key购买 nike

我想启动 Windows 资源管理器并登录网站。登录后,我想单击注销文本链接。但是我收到了这个错误:

Method invocation failed because [mshtml.HTMLDocumentClass] doesn't contain amethod named 'getElementsByClassName'At C:\Users\ntando.ntuli\Desktop\test.ps1:29 char:43+  $Link=$ie.Document.getElementsByClassName <<<< ("underline") | Where-Object {$_.ClassName -eq "underline"}    + CategoryInfo          : InvalidOperation: (getElementsByClassName:String) [], RuntimeException    + FullyQualifiedErrorId : MethodNotFound

Here is the code I am using

$IE = New-Object -COM InternetExplorer.Application;
$IE.Visible = $true;
$IE.Navigate("http://192.168.2.73:6500/ouaf/loginPage.jsp");

# Wait a few seconds and then launch the executable.
while ($IE.Busy -eq $true) {
Start-Sleep -Milliseconds 2000;
}

# The following UsernameElement, PasswordElement, and LoginElement need to be
# modified first. See the notes at the top of the script for more details.

$elementMatchText = "You are logged in as English System"
$IE.Document.getElementById("userId").value = "username"
$IE.Document.getElementByID("password").value="password"
$IE.Document.getElementById("loginButton").Click()

while ($IE.Busy -eq $true) {
Start-Sleep -Milliseconds 2000;
}

#Logout textlink classname
$Link = $ie.Document.getElementsByClassName("underline") |
Where-Object {$_.ClassName -eq "underline"}
$Link.Click()

最佳答案

似乎只能在文档的 documentElement 属性上调用 getElementsByClassName:

$ie.Document.documentElement.getElementsByClassName("underline")

关于windows - 方法 "getElementsByClassName"无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34785024/

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