我想启动 Windows 资源管理器并登录网站。登录后我想单击注销文本链接。但我收到此错误:
Method invocation failed because [mshtml.HTMLDocumentClass] doesn't contain a
method 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
这是我正在使用的代码
$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()
看来只能打电话了getElementsByClassName
on the documentElement
文档的属性:
$ie.Document.documentElement.getElementsByClassName("underline")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)