title: PowerShell - "Click" an HTML input element with type "submit"
body: <p>I'm looking at a webpage with an input of type "submit":</p>
  
  <pre><code>&lt;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"&gt;
  </code></pre>
  
  <p>I would like to use PowerShell to "click" this input.  My script looks like:</p>
  
  <pre><code>$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 
  </code></pre>
  
  <p>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 <a href="https://stackoverflow.com/questions/17721295/powershell-how-to-click-a-submit-type-input">here</a>, but get the errors:</p>
  
  <pre><code>You cannot call a method on a null-valued expression.
  At line:16 char:36
  + $commit = $doc.getElementsByTagName &lt;&lt;&lt;&lt; ("input")
      + CategoryInfo          : InvalidOperation: (getElementsByTagName:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>
  
  <p>and</p>
  
  <pre><code>You cannot call a method on a null-valued expression.
  At line:16 char:36
  + $commit = $doc.getElementsByTagName &lt;&lt;&lt;&lt; ("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 &lt;&lt;&lt;&lt; () }
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : ComMethodCOMException
  </code></pre>
  
  <p>respectively.</p>
  
  <p>How can I click this button?</p>