title: Powershell - click submit button on HTML code
body: <p>I tried many different ways to click submit button on HTML code, but always got error.  </p>
  
  <pre><code>&lt;form action="abnormal-times.aspx" method="post"&gt;
  Time out Minutes &lt;input name="Minutes" style="width: 100px;" value="5"&gt; Minutes.&lt;br&gt;
  Time out Hours &lt;input name="Minutes" style="width: 100px;" value="2"&gt; Hours.
  &lt;input onclick="submit()" type="button" value="submit"&gt;
  </code></pre>
  
  <p>With my powershell code:</p>
  
  <pre><code>$ie = New-Object -com InternetExplorer.Application 
  $ie.visible = $true
  $ie.navigate("http://localhost.com")
  
  while($ie.ReadyState -ne 4) { start-sleep -s 1 }
  
  $Link = $ie.Document.getElementsByValue("submit")
  $Link.click()
  </code></pre>
  
  <p>But always popup error.</p>
  
  <pre><code>Method invocation failed because [mshtml.HTMLDocumentClass] doesn't contain a method
   named 'getElementsByValue'.
  At C:\temp\Untitled1.ps1:28 char:42
  + $Link = $ie.Document.getElementsByValue &lt;&lt;&lt;&lt; ("submit")
      + CategoryInfo          : InvalidOperation: (getElementsByValue:String) [], Run 
     timeException
      + FullyQualifiedErrorId : MethodNotFound
  
  You cannot call a method on a null-valued expression.
  At C:\temp\Untitled1.ps1:29 char:14
  + $Link.click &lt;&lt;&lt;&lt; ()
      + CategoryInfo          : InvalidOperation: (click:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>
  
  <p>Now I changed into this:</p>
  
  <pre><code>$Link=$ie.Document.getElementsByTagName("button") | where-object {$_.type -eq "submit"}
  $Link.click()
  </code></pre>
  
  <p>The error came out:</p>
  
  <pre><code>You cannot call a method on a null-valued expression.
  At C:\Users\Work_Server\Desktop\joseph.ps1:29 char:10
  + $go.click &lt;&lt;&lt;&lt; ()
      + CategoryInfo          : InvalidOperation: (click:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>