I'm trying to automate logging in on a website, but I can't seem to use getElementById. getElementsByClassName("whatever")[0] seems to work, but the elements I need don't have class names and I can't change that.
I'm using PS 5, IE 11. Here's an example of my code, and the resulting exception.
$url = "https://google.com"
$ie = New-Object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate($url)
while ($ie.Busy){Start-Sleep -Milliseconds 1000}
$ie.document.getElementById("lst-ib").value = "test"
Error:
Exception from HRESULT: 0x800A01B6
At C:\gtest.ps1:6 char:1
+ $ie.document.getElementById("lst-ib").value = "test"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], NotSupportedException
+ FullyQualifiedErrorId : System.NotSupportedException