I'm looking at a webpage with an input of type "submit":
<input name="loginForm:j_idt56:loginButton" id="loginForm:j_idt56:loginButton" onclick="this.style.display='none'; document.getElementById('euLoginButDis').style.display='inline';" type="submit" value="Login">
I would like to use PowerShell to "click" this input. My script looks like:
$username = "USERNAME"
$password = "PASSWORD"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.navigate("URL")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById("loginForm:j_idt21:username:username").value= "$username"
$ie.document.getElementById("loginForm:j_idt42:password:passwordb").value = "$password"
# $ie.document.getElementById("loginForm:j_idt56:loginButton").submit()
start-sleep 20
# $ie.Document.body | Out-File -FilePath c:\web.txt
I'm using code from another user on StackOverflow, who I assume was interacting with a button input. But this is a "submit". I've tried the solutions posted here, but get the errors:
You cannot call a method on a null-valued expression.
At line:16 char:36
+ $commit = $doc.getElementsByTagName <<<< ("input")
+ CategoryInfo : InvalidOperation: (getElementsByTagName:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
and
You cannot call a method on a null-valued expression.
At line:16 char:36
+ $commit = $doc.getElementsByTagName <<<< ("input") | ? { $_.name -eq "commit" }
+ CategoryInfo : InvalidOperation: (getElementsByTagName:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "click" with "0" argument(s): "The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))"
At line:17 char:29
+ if ($commit) { $commit.click <<<< () }
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodCOMException
respectively.
How can I click this button?
User contributions licensed under CC BY-SA 3.0