I want to start Windows Explorer and login to a website. After logging in I want to click logout textlink. But I am getting this error:
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
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()