title: Programmatically click a webpage button
body: <p>How to programmatically click a webpage button in Java?</p>
  
  <p>Given this button:</p>
  
  <pre class="lang-html prettyprint-override"><code> &lt;div id="titlebutton" &gt;Button&lt;/div&gt;
  </code></pre>
  
  <p>In Javascript it would work like this:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>var newWin = window.open(siteYouHaveAccessTo);
  newWin.document.getElementById('titlebutton').click();
  </code></pre>
  
  <p>I was wondering how I would do this in Java, not Javascript (Is there a way of doing it with Java alone or do I have to import/use Javascript?).</p>
  
  <p>Edit:</p>
  
  <p>Clicking the Button will result in a call of a function called setText().
  I am not sure how I would send a similar request as this function?
  Would it help if I pasted the function code?</p>