Example #1
0
        private IE ViewUpdateLogFromMainPage(UpdateType updateType)
        {
            var uriFormat = "Logs/UpdateLog?BeginDate=01.09.2009 0:00:00&EndDate=15.01.2010 0:00:00&RegionMask=137438953471&updateType={0}";
            var uri       = String.Format(uriFormat, (int)updateType);
            var browser   = new IE(BuildTestUrl(uri));

            AssertText(BindingHelper.GetDescription((StatisticsType)updateType));
            AssertText("Клиентов, отвечающих условиям выборки");
            AssertText("Пользователь");
            AssertText("Клиент");

            browser.Links.Where(l => (l.Title != null) && l.Title.Equals("UserSettings")).First().Click();
            Assert.That(browser.Url, Is.StringContaining("/users/"));
            browser.Back();

            browser.Links.Where(l => (l.Title != null) && l.Title.Equals("ClientSettings")).First().Click();
            Assert.That(browser.Url, Is.StringContaining("/client/"));
            browser.Back();

            return(browser);
        }
Example #2
0
        public void Navigating()
        {
            using (var browser = new IE())
            {
                browser.AutoClose = false;
                browser.ShowWindow(NativeMethods.WindowShowStyle.Minimize);
                browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

                browser.GoTo("http://www.bing.com");

                browser.GoTo("http://www.pluralsight.com");

                browser.Back();

                browser.Forward();
            }
        }
Example #3
0
        // https://sourceforge.net/tracker/?func=detail&aid=2897406&group_id=167632&atid=843727
        public void Search_for_watin_on_google_using_page_class()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                var searchPage = browser.Page <GoogleSearchPage>();
                searchPage.SearchCriteria.TypeText("WatiN");
                searchPage.SearchButton.Click();

                Assert.IsTrue(browser.ContainsText("WatiN"));
                browser.Back();

                //This line throws UnauthorizedAccessException.
                searchPage.SearchCriteria.TypeText("Search Again");
                searchPage.SearchButton.Click();
                Assert.IsTrue(browser.ContainsText("Glenn"));
            }
        }
Example #4
0
 public void TestEMailFriends()
 {
     using (var browser = new IE())
     {
         browser.Setup();
         browser.GoToHomePage();
         //job search
         browser.TextField(Find.ById("Keywords")).TypeText("linkme");
         browser.Div(Find.ById("search")).Click();
         browser.WaitForComplete();
         Assert.AreEqual(browser.Url, new ReadOnlyApplicationUrl(false, "~/search/jobs/advanced?performSearch=true&keywords=linkme").AbsoluteUri);
         //none CareerOne job, old job ad page, has 'Already a member?'
         browser.Link(Find.ByClass("title") && Find.ByText("LinkMe test job ads - non CareerOne")).Click();
         browser.WaitForComplete();
         Assert.IsTrue(browser.Elements.Filter(Find.ByText("Already a member?")).Count >= 1);
         browser.Back();
         //CareerOne job, new job ad page, has .emailbutton
         browser.Link(Find.ByClass("title") && Find.ByText("LinkMe test job ads")).Click();
         browser.WaitForComplete();
         Assert.AreEqual(browser.Eval("$(\".emailbutton\").length"), "1");
         //click email button, show email layer
         browser.Div(Find.ByClass("emailbutton")).Click();
         browser.WaitForComplete();
         Assert.AreEqual(browser.Eval("$(\".emailbutton\").hasClass(\"active\")"), "true");
         Assert.AreEqual(browser.Div(Find.ByClass("emaillayer")).Style.Display, "block");
         Assert.AreEqual(browser.Div(Find.ByClass("err-info")).Style.Display, "none");
         Assert.AreEqual(browser.Div(Find.ByClass("succ-info")).Style.Display, "none");
         //click cancel button, hide email layer
         browser.Eval("$(\".emaillayer .cancelbutton\").click();");
         browser.WaitForComplete();
         Assert.AreEqual(browser.Eval("$(\".emailbutton.active\").length"), "0");
         Assert.AreEqual(browser.Div(Find.ByClass("emaillayer")).Style.Display, "none");
         //click email button again, click submit then, test empty input
         browser.Div(Find.ByClass("emailbutton")).Click();
         browser.WaitForComplete();
         browser.Eval("$(\".emaillayer .sendbutton\").click();");
         browser.WaitForComplete();
         Assert.AreEqual(browser.Eval("$(\"#FromName\").closest(\".control\").hasClass(\"error\")"), "true");
         Assert.AreEqual(browser.Eval("$(\"#FromName\").closest(\".field\").find(\".error-msg\").length"), "1");
         Assert.AreEqual(browser.Eval("$(\"#FromEmailAddress\").closest(\".control\").hasClass(\"error\")"), "true");
         Assert.AreEqual(browser.Eval("$(\"#FromEmailAddress\").closest(\".field\").find(\".error-msg\").length"), "1");
         Assert.AreEqual(browser.Eval("$(\"#ToNames\").closest(\".control\").hasClass(\"error\")"), "true");
         Assert.AreEqual(browser.Eval("$(\"#ToNames\").closest(\".field\").find(\".error-msg\").length"), "1");
         Assert.AreEqual(browser.Eval("$(\"#ToEmailAddresses\").closest(\".control\").hasClass(\"error\")"), "true");
         Assert.AreEqual(browser.Eval("$(\"#ToEmailAddresses\").closest(\".field\").find(\".error-msg\").length"), "1");
         Assert.AreEqual(browser.Div(Find.ByClass("err-info")).Style.Display, "block");
         Assert.AreEqual(browser.Div(Find.ByClass("succ-info")).Style.Display, "none");
         //test numbers of ToNames and ToEmailAddresses are diff
         browser.TextField(Find.ById("ToNames")).TypeText("c,d");
         browser.TextField(Find.ById("ToEmailAddresses")).TypeText("*****@*****.**");
         browser.Eval("$(\".emaillayer .sendbutton\").click();");
         browser.WaitForComplete();
         Assert.AreEqual(browser.Eval("$(\".err-info:contains('match')\").length"), "1");
         Assert.AreEqual(browser.Div(Find.ByClass("err-info")).Style.Display, "block");
         Assert.AreEqual(browser.Div(Find.ByClass("succ-info")).Style.Display, "none");
         //test succ
         browser.TextField(Find.ById("FromName")).TypeText("a");
         browser.TextField(Find.ById("FromEmailAddress")).TypeText("*****@*****.**");
         browser.TextField(Find.ById("ToNames")).Clear();
         browser.TextField(Find.ById("ToNames")).TypeText("b,c");
         browser.TextField(Find.ById("ToEmailAddresses")).Clear();
         browser.TextField(Find.ById("ToEmailAddresses")).TypeText("[email protected],[email protected]");
         browser.Eval("$(\".emaillayer .sendbutton\").click();");
         browser.WaitForComplete();
         Assert.AreEqual(browser.Div(Find.ByClass("err-info")).Style.Display, "none");
         Assert.AreEqual(browser.Div(Find.ByClass("succ-info")).Style.Display, "block");
     }
 }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ie">The navigator to operate</param>
        public override void Do(IE ie)
        {
            if (ie == null)
            {
                ie = Wxs.Instance.Ie;
            }
            if ((path == null) || (path == String.Empty))
            {
                path = "C:\\";
            }
            string[] splt = ie.Url.Split(new char[] { '/' });
            if (splt.Length < 3)
            {
                throw new ApplicationException("Invalid url to retrive test page");
            }
            ie.GoTo(splt[0] + "//" + splt[2] + "/test.aspx");
            if (ie.ContainsText("Session State"))
            {
                Dictionary <String, String> valuesToSave = new Dictionary <string, string>();
                string[] lines = ie.Text.Split(new char[] { '\n' });
                foreach (string line in lines)
                {
                    string[] splLine = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (splLine.Length == 2)
                    {
                        string key = splLine[0].Replace("+", String.Empty);
                        key = key.Replace("|", " ").Trim();
                        string value = splLine[1].Trim();
                        if (!valuesToSave.ContainsKey(key))
                        {
                            valuesToSave.Add(key, value);
                        }
                    }
                }
                string fileName;
                if ((valuesToSave.ContainsKey("UserName")) & valuesToSave.ContainsKey("SponsorID"))
                {
                    fileName = String.Format("{0}\\{2}_{1}.txt", path, valuesToSave["UserName"], valuesToSave["SponsorID"]);
                }
                else if (valuesToSave.ContainsKey("PersonID"))
                {
                    fileName = String.Format("{0}\\{1}.txt", path, valuesToSave["PersonID"]);
                }
                else
                {
                    fileName = String.Format("{0}\\{1}.txt", path, Name);
                }
                Wxs.Instance.Log.InfoFormat("Saving test page results to file : {0}", fileName);
                using (StreamWriter sw = new StreamWriter(fileName))
                {
                    sw.WriteLine("Test executed on {0}", DateTime.Now.ToString("g"));
                    sw.WriteLine("On : {0}\n\t\t***************", Wxs.Instance.Ie.Url);
                    foreach (KeyValuePair <string, string> kvp in valuesToSave)
                    {
                        sw.WriteLine(kvp.Key + " = " + kvp.Value);
                    }
                }
                ie.Back();
            }

            else
            {
                Wxs.Instance.Log.Error("Test page not available?");
            }
        }
Example #6
0
        private static void FirstimeLoginChangePassword()
        {
            TreasuryDataContext tdc             = new TreasuryDataContext();
            List <string>       defaultpassword = new List <string>()
            {
                "NCO", null, "invalid password", "Account locked", ""
            };
            var passwordchangeusersnames = (from u in tdc.CybersourceGatewayTranDownloadTrackings
                                            where u.ReportDate.Equals(DateTime.Parse(reportDate)) && u.isDownLoadSuccess.Value.Equals(false) && !(defaultpassword.Contains(u.NewPasswordSet))
                                            select u);

            foreach (CybersourceGatewayTranDownloadTracking t in passwordchangeusersnames)
            {
                string organizationId = t.UserName;
                string username       = t.UserName;
                string password       = t.NewPasswordSet;
                string newpassword    = "";
                string merchantid     = t.MerchantId;

                List <string> validmessage = new List <string>();
                validmessage.Add("Welcome to the CyberSource Business Center");
                validmessage.Add("The specified login credentials are incorrect");
                validmessage.Add("The specified user name has been locked.");

                using (var browser = new IE("https://ebc.cybersource.com/ebc/login/Login.do#"))
                {
                    browser.Link(Find.ByText("change")).Click();
                    browser.TextField(Find.ByName("organizationId")).TypeText(organizationId);
                    browser.TextField(Find.ByName("username")).TypeText(username);
                    browser.TextField(Find.ByName("password")).TypeText(password);
                    browser.Button(Find.ByValue("Login")).Click();

                    if (browser.ContainsText(validmessage[0]) || browser.ContainsText(validmessage[1]) || browser.ContainsText(validmessage[2]))
                    {
                        if (browser.ContainsText(validmessage[0]))
                        {
                            newpassword = password;
                        }
                        else if (browser.ContainsText(validmessage[1]))
                        {
                            newpassword = "******";
                        }
                        else
                        {
                            newpassword = "******";
                        }

                        tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                    }
                    else
                    {
                        //newpassword = "******" ;
                        //browser.TextField(Find.ByName("password")).TypeText(password);
                        //browser.TextField(Find.ByName("newPassword")).TypeText(newpassword);
                        //browser.TextField(Find.ByName("newPasswordConfirm")).TypeText(newpassword);
                        //browser.Button(Find.ByValue("Submit")).Click();

                        //if (browser.ContainsText("Secret Profile Setup"))
                        //{
                        //    if (!(browser.TextField(Find.ByName("answer")).Text.Length > 1))
                        //    {
                        //        browser.TextField(Find.ByName("answer")).TypeText("NCO");
                        //    }

                        //    browser.Button(Find.ByValue("Submit Request")).Click();

                        //    string sql = "Update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet= '" + newpassword + "' where CybersourceGatewayTranDownloadTracking_id=" + t.CybersourceGatewayTranDownloadTracking_id;
                        //    tdc.ExecuteCommand(sql);

                        //    tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");

                        //}
                        //else
                        //{
                        //    browser.Back();
                        //    newpassword = "******";
                        //    browser.TextField(Find.ByName("password")).TypeText(password);
                        //    browser.TextField(Find.ByName("newPassword")).TypeText(newpassword);
                        //    browser.TextField(Find.ByName("newPasswordConfirm")).TypeText(newpassword);
                        //    browser.Button(Find.ByValue("Submit")).Click();


                        //    if (browser.ContainsText("Secret Profile Setup"))
                        //    {
                        //        if (!(browser.TextField(Find.ByName("answer")).Text.Length > 1))
                        //        {
                        //            browser.TextField(Find.ByName("answer")).TypeText("NCO");
                        //        }

                        //        browser.Button(Find.ByValue("Submit Request")).Click();

                        //        string sql = "Update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet= '" + newpassword + "' where CybersourceGatewayTranDownloadTracking_id=" + t.CybersourceGatewayTranDownloadTracking_id;
                        //        tdc.ExecuteCommand(sql);

                        //        tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");

                        //    }
                        //    else
                        //    {
                        //browser.Back();

                        for (int i = 12; i <= 30; i++)
                        {
                            newpassword = "******" + i.ToString();
                            browser.TextField(Find.ByName("password")).TypeText(password);
                            browser.TextField(Find.ByName("newPassword")).TypeText(newpassword);
                            browser.TextField(Find.ByName("newPasswordConfirm")).TypeText(newpassword);
                            browser.Button(Find.ByValue("Submit")).Click();

                            if (browser.ContainsText("Secret Profile Setup"))
                            {
                                if (!(browser.TextField(Find.ByName("answer")).Text.Length > 1))
                                {
                                    browser.TextField(Find.ByName("answer")).TypeText("NCO");
                                }

                                browser.Button(Find.ByValue("Submit Request")).Click();

                                string sql = "Update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet= '" + newpassword + "' where CybersourceGatewayTranDownloadTracking_id=" + t.CybersourceGatewayTranDownloadTracking_id;
                                tdc.ExecuteCommand(sql);

                                tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                                break;
                            }
                            else if (browser.ContainsText("Your new password cannot be a previously used password."))
                            {
                                browser.Back();
                            }

                            else if (browser.ContainsText("You cannot change your password more than three times in 24 hours"))
                            {
                                browser.Back();
                                browser.Back();
                                break;
                            }
                            //}
                            //}
                        }
                    }
                }
            }
        }
Example #7
0
        private static void PasswordChange()
        {
            bool nextstage = false;

            var passwordchangeusersnames = (from u in tdc.CybersourceGatewayTranDownloadTrackings
                                            where u.ReportDate.Equals(DateTime.Parse(reportDate)) && u.isDownLoadSuccess.Value.Equals(false) && u.NewPasswordSet.Equals(null)
                                            select u);

            foreach (CybersourceGatewayTranDownloadTracking t in passwordchangeusersnames)
            {
                string merchantid     = t.MerchantId;
                string username       = t.UserName;
                string password       = "******";
                string organizationId = t.UserName;
                string newpassword    = "";

                List <string> validmessage = new List <string>();
                validmessage.Add("Welcome to the CyberSource Business Center");
                validmessage.Add("The specified user name has been locked.");

                using (var browser = new IE("https://ebc.cybersource.com/ebc/login/Login.do#"))
                {
                    browser.Link(Find.ByText("change")).Click();
                    browser.TextField(Find.ByName("organizationId")).TypeText(organizationId);
                    browser.TextField(Find.ByName("username")).TypeText(username);
                    browser.TextField(Find.ByName("password")).TypeText(password);
                    browser.Button(Find.ByValue("Login")).Click();

                    if (browser.ContainsText(validmessage[0]) || browser.ContainsText(validmessage[1]))
                    {
                        if (browser.ContainsText(validmessage[0]))
                        {
                            newpassword = password;
                        }
                        else if (browser.ContainsText(validmessage[1]))
                        {
                            newpassword = "******";
                        }


                        tdc.ExecuteCommand("update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet='" + newpassword + "' where MerchantId = '" + merchantid + "'");
                        tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                    }
                    else if (browser.ContainsText("Secret Profile Setup"))
                    {
                        if (!(browser.TextField(Find.ByName("answer")).Text.Length > 1))
                        {
                            browser.TextField(Find.ByName("answer")).TypeText("NCO");
                        }

                        browser.Button(Find.ByValue("Submit Request")).Click();
                        string sql = "Update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet= '" + newpassword + "' where CybersourceGatewayTranDownloadTracking_id=" + t.CybersourceGatewayTranDownloadTracking_id;
                        tdc.ExecuteCommand(sql);
                        tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                    }
                    else
                    {
                        browser.Back();
                        password = "******";
                        browser.Link(Find.ByText("change")).Click();
                        browser.TextField(Find.ByName("organizationId")).TypeText(organizationId);
                        browser.TextField(Find.ByName("username")).TypeText(username);
                        browser.TextField(Find.ByName("password")).TypeText(password);
                        browser.Button(Find.ByValue("Login")).Click();

                        if (browser.ContainsText(validmessage[0]) || browser.ContainsText(validmessage[1]))
                        {
                            if (browser.ContainsText(validmessage[0]))
                            {
                                newpassword = password;
                            }
                            else if (browser.ContainsText(validmessage[1]))
                            {
                                newpassword = "******";
                            }

                            tdc.ExecuteCommand("update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet='" + newpassword + "' where MerchantId = '" + merchantid + "'");
                            tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                        }
                        else if (browser.ContainsText("Secret Profile Setup"))
                        {
                            if (!(browser.TextField(Find.ByName("answer")).Text.Length > 1))
                            {
                                browser.TextField(Find.ByName("answer")).TypeText("NCO");
                            }

                            browser.Button(Find.ByValue("Submit Request")).Click();
                            string sql = "Update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet= '" + newpassword + "' where CybersourceGatewayTranDownloadTracking_id=" + t.CybersourceGatewayTranDownloadTracking_id;
                            tdc.ExecuteCommand(sql);
                            tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                        }
                        else
                        {
                            nextstage = step1_RequestForgottenPassword(organizationId, username);

                            if (nextstage)
                            {
                                nextstage = step2_RecoverPassword(organizationId, username, ref password);
                            }

                            string sql = "Update dbo.T_CybersourceGatewayTranDownloadTracking set NewPasswordSet= '" + password + "' where CybersourceGatewayTranDownloadTracking_id=" + t.CybersourceGatewayTranDownloadTracking_id;
                            tdc.ExecuteCommand(sql);

                            tdc.ExecuteCommand("update dbo.T_CybersourceGatewayMerchantConfig set Password='******' where MerchantId = '" + merchantid + "'");
                        }
                    }
                }
            }
        }