title: Facebook Login with Selenium for C#
body: <p>I've been playing with the Selenium C# framework and been trying to do a facebook login, but without any luck.</p>
  
  <p>This is what i got so far (based on this post: <a href="https://stackoverflow.com/questions/8845614/testing-a-facebook-connect-application-using-selenium/8867886#8867886">Testing a Facebook Connect application using Selenium?</a>). I can't get it to work though.</p>
  
  <pre><code>ISelenium sel = new DefaultSelenium("localhost", 4444, "*chrome", "http://facebook.com");
  public void LoginWithEmailAndPassword(string email, string pass)
  {
      sel.Start();
      sel.Open("http://www.facebook.com");
      sel.ClickAt("//img[\\@alt='Facebook']", "User clicks on Facebook Login");
      sel.WaitForPopUp("", "3000");
      sel.SelectPopUp("");
      sel.Type("email", email);
      sel.Type("pass", pass);
      sel.KeyPress("pass", "\\13");
      sel.SelectWindow("null");
  }
  </code></pre>
  
  <p>So if someone could provide me with some sample code for how to do this, or guide me in the right direction, it would be appreciated.</p>
  
  <p><strong>Resolved</strong></p>
  
  <p>By using the record feature of the Firefox Selenium plugin I got the id's and the functions i needed to get it working. The login button seemed to require an XPath definition, which I also got from the Selenium IDE.</p>
  
  <pre><code>ISelenium sel = new DefaultSelenium("localhost", 4444, "*chrome", "http://facebook.com");
  public void LoginWithEmailAndPassword(string email, string pass)
  {
      sel.Start();
      sel.Open("/");
      sel.Type("id=email", email);
      sel.Type("id=pass", pass);
      sel.Click("//label[@id='loginbutton']/input");
  }
  </code></pre>