title: How does one programmatically click a button via the browser console [code inside]
body: <p>For some reason, I am able to click some links/buttons, but cannot for buttons/anything that has an onclick attribute.
  For example:
  my JavaScript code I input into the browser's console:</p>
  
  <pre><code>var o = document.getElementsByName("takepic"); 
  for (var i = 0; i &lt; 1000; i++){
      o.click();
      console.log(i);
  }
  </code></pre>
  
  <p>I put console.log so I know what the browser is doing, and where it currently is at.</p>
  
  <p>The html code on the page:</p>
  
  <pre><code>&lt;form&gt;
      &lt;input type="button" value="Configure..." onclick="webcam.configure()"&gt;
      &amp;nbsp;&amp;nbsp;
      &lt;input type="button" value="Take Snapshot" onclick="take_snapshot()" name="takepic"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So basically, I want to take rapid snapshots using the browser console, but when I enter in my code, I get this error: </p>
  
  <blockquote>
    <p>TypeError: Object # has no method 'click'</p>
  </blockquote>
  
  <p>When I do use the same code, say for re-adding friends on facebook, and I use this:</p>
  
  <pre><code>var o = document.getElementsByName("fbaddfriend_example"); 
  for (var i = 0; i &lt; o.length; i++){
      o[i].click(); 
      console.log(i);
  }
  </code></pre>
  
  <p>It definitely works.
  I'm just trying to do the same with a button on a page, but with no avail.</p>