public static IWebDriver Authenticate()
{
string email = "admin@test";
IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());
//webDriver.Manage().Window.Maximize();
webDriver.Navigate().GoToUrl("http://dev.icms/Account/Login");
//Enter email address on login page
IWebElement emailLogin = webDriver.FindElement(By.Id("Email"));
emailLogin.Clear();
emailLogin.SendKeys(email);
IWebElement authenticateButton = webDriver.FindElement(By.Id("requestauth"));
authenticateButton.Click();
//this should have sent me an email
//Let's pretend we got the email and check the server for the authtoken and plug it into the URL
string token = HttpUtility.UrlEncode(TestUtilities.AuthenticationUtil.GetAuthToken(email));
string goToUrl = string.Format("http://dev.icms/account/authorize/?authtoken={0}&email={1}&returnUrl=%2f", token, email);
webDriver.Quit();
webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());
webDriver.Navigate().GoToUrl(goToUrl);
//Check DOM to see if we are logged in
IWebElement elem = webDriver.FindElement(By.CssSelector("h1"));
//webDriver.Quit();
if (elem.Text == "Welcome Admin Development")
{
return webDriver;
}
return null;
}