title: Automating JavaScript confirmation prompt in IE using PowerShell
body: <p>I have the following JavaScript code in an HTML page:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      function confirmAutoTransitionSelection() {
          var autoTransition = 'OFF';
          if (document.getElementById('autoTransitionON').checked) {
              autoTransition = 'ON';
          }
          return confirm('Are you sure you want to turn ' + autoTransition + ' the Auto Transition Setting?');
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>Also in the HTML code, I have the following input buttons that I'm auto-clicking with PowerShell script:</p>
  
  <pre><code>&lt;form method="post"&gt;
  Auto Transition
  &lt;input type="radio" id="autoTransitionON" name="autoTransition" checked value="true" /&gt; ON
  &lt;input type="radio" name="autoTransition" value="false" /&gt; OFF
  &lt;input class="submitBtn" type="submit" name="autoTransitionBtn" onclick="javascript:return confirmAutoTransitionSelection();" value="[Update]"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And here is my PowerShell script:</p>
  
  <pre><code>$ie = new-object -com "InternetExplorer.Application"
  $ie.Navigate("http://localhost/test/")
  While ($ie.Busy) {Sleep 2}
  $doc = $ie.Document
  $autobutton = $doc.getElementById("autoTransitionON").Click()
  $btn = $doc.getElementsByTagName("input")
  $autotransbtn = $btn | ? {$_.Name -eq "autoTransitionBtn"}
  $autotransbtn.Click()
  $ie.Quit()
  </code></pre>
  
  <p>I don't have any problems auto-clicking the input buttons with the PowerShell script, but the JavaScript is throwing a confirmation that has to be clicked to confirm the change. This is where I'm having a problem. How do I auto-click the JavaScript confirm?</p>
  
  <p>Thanks in advance!</p>