Exemplo n.º 1
0
        private static HtmlDocument AddUserAccount(BrowserSession session, HtmlDocument response, UserAccount user)
        {
            var token = GetRequestVerificationToken(response);
            if (!String.IsNullOrEmpty(token))
            {
                session.FormElements[SessionConfig.Headers.RequestVerificationToken] = token;
                session.FormElements[SessionConfig.FormElements.Email] = user.Email;
                session.FormElements[SessionConfig.FormElements.Password] = user.Password;
                session.FormElements[SessionConfig.FormElements.ConfirmPassword] = user.Password;

                return session.Post(SessionConfig.Urls.CreateUser);
            }
            return null;
        }
Exemplo n.º 2
0
        private static string CheckIfFailed(HtmlDocument response, List<string> failedUsers, UserAccount user)
        {
            var validationErrors = response
                        .DocumentNode
                        .SelectNodes(SessionConfig.FormElements.ValidationTag);

            if (validationErrors != null)
            {
                return String.Format("User Failed: {0}. Reason: {1}", user.Email, validationErrors.FirstOrDefault().InnerText);
            }

            //check for the oops error page
            if(response.DocumentNode.SelectSingleNode("//head/title") != null && response.DocumentNode.SelectSingleNode("//head/title").InnerText == SessionConfig.FormElements.BrowserTitle)
            {
                return String.Format("User Failed: {0}. Redirected to error page", user.Email);
            }

            return "";
        }