title: emulating a browser programmatically in C# / .Net
body: <p>We would like to automate certain tasks in a website, like having a user 'login', perform some functionality, read their account history etc.</p>
  
  <p>We have tried emulating this with normal POST/GETs, however the problem is that for example for 'login', the website uses javascript code to execute an AJAX call, and also generate some random tokens.  </p>
  
  <p>Is it possible to literally emulate a web-browser?  For example:</p>
  
  <ul>
  <li>Visit 'www.[test-website].com'</li>
  <li>Fill in these DOM items
  <ul>
  <li>DOM item 'username' fill in with 'testuser'</li>
  <li>DOM item 'password' fill in with 'testpass'</li>
  <li>Click' button DOM item 'btnSubmit'</li>
  </ul></li>
  <li>Visit account history
  <ul>
  <li>Read HTML (So we can parse information about each distinct history item)</li>
  </ul></li>
  <li>...</li>
  </ul>
  
  <p>The above could be translated into say the below sample code:</p>
  
  <pre><code>var browser = new Browser();
  var pageHomepage = browser.Load("www.test-domain.com");
  pageHomepage.DOM.GetField("username").SetValue("testUser");
  pageHomepage.DOM.GetField("password").SetValue("testPass");
  pageHomepage.DOM.GetField("btnSubmit").Click();
  var pageAccountHistory = browser.Load("www.test-domain.com/account-history/");
  var html = pageAccountHistory.GetHtml();
  var historyItems = parseHistoryItems(html); 
  </code></pre>