Facebook Login with Selenium for C#

I've been playing with the Selenium C# framework and been trying to do a facebook login, but without any luck.

This is what i got so far (based on this post: Testing a Facebook Connect application using Selenium?). I can't get it to work though.

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");
}

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.

Resolved

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.

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");
}

Answers


Try use WebDriver:

IWebDriver driver = new FireFoxDriver();
driver.GoToUrl("www.facebook.com");

var element = driver.FindElement(By.Id("email"));
element.SendKeys(email);
...
element = driver.FindElement(By.Id("submit button id"));
element.Click();

This link could help you get start.


Need Your Help

Do we have console for codeigniter

php ruby-on-rails django codeigniter codeigniter-2

I have been working on codeigniter recently and I am surprised that I didn't find anything relevant regarding codeigniter console. So basically I will like to know whether we have console in codeig...

How to keep radio button value inside php variable without error

php html forms

Let me explain more in details what I am trying to do.