Ejemplo n.º 1
0
        public void Should_save_a_visit()
        {
            new DatabaseTester().Clean();

            var url = "http://localhost:1234/";
            using (var ie = new IE(url))
            {
                ie.TextField("PathAndQuerystring").TypeText("/MyUrl");
                ie.TextField("LoginName").TypeText("SomeComputer\\ThisUser");
                ie.Button("submit").Click();

                ie.ContainsText("/MyUrl");
                ie.ContainsText("SomeComputer\\ThisUser").ShouldBeTrue();
            }
        }
Ejemplo n.º 2
0
 public void Verify_WebsiteUp()
 {
     using (var browser = new IE("http://localhost/Sample.Web_deploy"))
     {
         var hasText = browser.ContainsText("Getting started");
         Assert.IsTrue(hasText);
     }
 }
Ejemplo n.º 3
0
        public void Page_With_An_Action()
        {
            using (var browser = new IE("http://www.google.com")) {
                browser.Page<GoogleSearchPage>().SearchFor("Robby");

                Assert.IsTrue(browser.ContainsText("Robby"));
            }
        }
        public void GenerateNummericSequenceUITest()
        {
                       
            using (var browser = new IE("http://localhost:10827/"))
            {
                browser.TextField(Find.ByName("txtNumber")).TypeText("15");
                browser.Button(Find.ByName("btnGenerate")).Click();
                Assert.IsTrue(browser.ContainsText("All Numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 "));
                Assert.IsTrue(browser.ContainsText("All Odd Numbers: 1, 3, 5, 7, 9, 11, 13, 15 "));
                Assert.IsTrue(browser.ContainsText("All Even Numbers: 0, 2, 4, 6, 8, 10, 12, 14 "));
                Assert.IsTrue(browser.ContainsText("All Extended FizzBuzzs: Z, 1, 2, C, 4, E, C, 7, 8, C, E, 11, C, 13, 14, Z "));
                Assert.IsTrue(browser.ContainsText("All Fibonacci Numbers: 0, 1, 1, 2, 3, 5, 8, 13 "));

                System.Threading.Thread.Sleep(5000);

            }
            
        }
Ejemplo n.º 5
0
        public void SearchForWatiNOnGoogle()
        {
            using (var browser = new IE("http://www.google.com")) {
                browser.TextField(Find.ByName("q")).TypeText("WatiN");
                browser.Button(Find.ByName("btnG")).Click();

                Assert.IsTrue(browser.ContainsText("WatiN"));
            }
        }
Ejemplo n.º 6
0
 public void Save_should_fail_when_GET_attempted()
 {
     using (IE browser = new IE(BuildTestUrl("post/save.aspx")))
     {
         Assert.IsTrue(browser.ContainsText(
             @"Access to the action [save] on controller [post] is not allowed to the http verb [GET]."),
             "Action accessible via GET");
     }
 }
        public void Home_HasMvcStoreHasTitle_True()
        {
            var browser = new IE("http://localhost:1100/");

            browser.BringToFront();
            Assert.IsTrue(browser.ContainsText("ASP.NET MVC MUSIC STORE"));

            browser.Close();
        }
Ejemplo n.º 8
0
        public void AddPost_ShouldRenderAddForm_AndConfirmPostSaved()
        {
            using(IE browser = new IE(BuildTestUrl("post/add.aspx")))
            {
                Assert.IsTrue(browser.ContainsText("Ben Lovell's Blog"),
                    "No header text found");
                Assert.IsTrue(browser.ContainsText("Add Post"),
                    "Add Post not found");

                browser.TextField(Find.ByName("post.Title")).TypeText("Title");
                browser.TextField(Find.ByName("post.Description")).TypeText("Description");
                browser.TextField(Find.ByName("post.Content")).TypeText("Content");
                browser.Button(Find.ByValue("Submit")).Click();

                Assert.IsTrue(browser.ContainsText(@"The post titled: 'Title' was created!"),
                    "Correct confirmation was not displayed");
            }
        }
Ejemplo n.º 9
0
 public void RunSmokeTest()
 {
     using (var browser = new IE("http://www.google.com"))
     {
         const string search = "WatiN";
         browser.TextField(Find.ByName("q")).TypeText(search);
         browser.Button(Find.ByName("btnG")).Click();
         Assert.IsTrue(browser.ContainsText(search));
     }
 } 
Ejemplo n.º 10
0
        public void HelloWatin(string search)
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.TextField(Find.ByName("q")).TypeText(search);
                browser.Button(Find.ByName("btnG")).Click();

                Assert.IsTrue(browser.ContainsText(search));
            }
        }
Ejemplo n.º 11
0
 public static bool isBusy(this IE ie)
 {
     if (ie.Visible && ie.ContainsText("Home"))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 12
0
        public void Demonstrate_speed()
        {
            new DatabaseTester().Clean();

            var url = "http://localhost:1234/";
            using (var ie = new IE(url))
            {
                for (int i = 0; i < 50; i++)
                {
                    ie.GoTo("http://localhost:1234/");
                    ie.TextField("PathAndQuerystring").Value = "/MyUrl";
                    ie.TextField("LoginName").Value = "SomeComputer\\ThisUser";
                    ie.Button("submit").Click();

                    ie.ContainsText("/MyUrl");
                    ie.ContainsText("SomeComputer\\ThisUser").ShouldBeTrue();
                }
                
            }
        }
Ejemplo n.º 13
0
        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"));
            }
        }
        public void Home_ClickOnRockContainsRockAlbumText_True()
        {
            using (var browser = new IE("http://localhost:1100/"))
            {

                browser.BringToFront();

                browser.Link(Find.ByText("Rockssss")).Click();
                Assert.IsTrue(browser.ContainsText("Rock Albums"));

            }
        }
Ejemplo n.º 15
0
        void StressThread()
        {
            //Settings.WaitForCompleteTimeOut = 3600;
            //Settings.WaitUntilExistsTimeOut = 3600;
            
            using (IE ie = new IE("http://*****:*****@"C:\Users\Chris\Downloads\Firefox Setup 7.0.exe");

                //_waitEvent.WaitOne();
                ie.Link(Find.ById("uploadButton")).Click();

                while (!ie.ContainsText("Upload Result"))
                {
                    Thread.Sleep(1000);
                    //ie.WaitForComplete();
                }

                Assert.True(ie.ContainsText("Complete"));

                ie.Link(Find.ById("newUploadButton")).Click();
                ie.WaitForComplete();

                SetFileUpload(ie, "slickUpload_selector_html_file0", @"C:\Users\Chris\Downloads\SlickUpload-6.1-S3MetadataFix.zip");
                SetFileUpload(ie, "slickUpload_selector_html_file1", @"C:\Users\Chris\Downloads\MSBuild Extension Pack April 2011 (All Files) (1).zip");
                ie.Link(Find.ById("uploadButton")).Click();

                while (!ie.ContainsText("Upload Result"))
                {
                    Thread.Sleep(1000);
                    //ie.WaitForComplete();
                }

                Assert.True(ie.ContainsText("Complete"));

                //Thread.Sleep(10000);
            }
        }
        public void WpLoadingTest()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.TextField(Find.ByName("q")).TypeText("WatiN");
                browser.Button(Find.ByName("btnG")).Click();

                var waitForWithAssert = new WaitForPage(() =>
                {
                    Assert.IsTrue(browser.ContainsText("WatiN"));
                });
            }
        }
Ejemplo n.º 17
0
        public void SetUp()
        {
            bool IsWebStarted;
            rootUrl = string.Format("http://*****:*****@".UnitTest")) ;
                    
                    //Environment.CurrentDirectory.Substring(0,Environment.CurrentDirectory.LastIndexOf('\\'));
                string commandArgs = string.Format(" /path:\"{0}\" /port:{1} /vapth:\"/{2}\"", rootPhyPath, devServerPort, rootpath);

                cmdProcess = new Process();
                cmdProcess.StartInfo.Arguments = commandArgs;
                cmdProcess.StartInfo.CreateNoWindow = true;
                cmdProcess.StartInfo.FileName = command;
                cmdProcess.StartInfo.UseShellExecute = false;
                cmdProcess.StartInfo.WorkingDirectory = command.Substring(0, command.LastIndexOf('\\'));
               if( !cmdProcess.Start())
                   throw new Exception("Cannot start webserver");
                
                // .. and try one more time to see if the server is up
                ie.GoTo(rootUrl);
            }
            Assert.IsTrue(ie.ContainsText("Directory Listing -- /"));

            // Give some time to crank up
            Thread.Sleep(1000);
        }
        public void UnsuccessfulAdministrationLogin()
        {
            bool result;
            using (var browser = new IE("http://localhost:1200/"))
            {
                browser.Link(Find.ByText("Admin")).Click();
                browser.TextField(Find.ById("UserName")).TypeText("admin");
                browser.TextField(Find.ById("Password")).TypeText("admin");

                browser.Element(Find.ByValue("Log On")).Click();

                result = browser.ContainsText("Login was unsuccessful.");
            }

            Assert.That(result, "Browser Url is incorrect");
        }
        public void Adding_Items_ToCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                Assert.IsTrue(browser.ContainsText("8.99"));
            }
        }
        public void Should_update_product_price_successfully()
        {
            using (var ie = new IE("http://localhost:8084/"))
            {
                ie.Link(Find.ByText("Products")).Click();

                ie.Link(Find.ByText("Edit")).Click();

                var priceField = ie.TextField(Find.ByName("Price"));

                priceField.Value = "389.99";

                ie.Button(Find.ByValue("Save")).Click();

                ie.Url.ShouldEqual("http://localhost:8084/Product");

                ie.ContainsText("389.99").ShouldBeTrue();
            }
        }
        public void RemoveItemsFromCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                browser.Link(Find.BySelector("a.RemoveLink")).Click();

                Assert.IsTrue(browser.ContainsText("0"));

            }
        }
        public void Should_be_able_to_edit_conference()
        {
            using (var ie = new IE("http://localhost:8084"))
            {
                var conferencesLink = ie.Link(Find.ByText("Conferences"));
                conferencesLink.Click();

                var editCodeMashLink = ie.Link(Find.ByText("Edit"));
                editCodeMashLink.Click();

                var nameBox = ie.TextField(Find.ByName("Name"));
                nameBox.TypeText("CodeMashFoo");

                var submitBtn = ie.Button(Find.ByValue("Save"));
                submitBtn.Click();

                ie.Url.ShouldEqual("http://localhost:8084/Conference");

                ie.ContainsText("CodeMashFoo").ShouldBeTrue();
            }
        }
Ejemplo n.º 23
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 + "'");

                        }
                    }
                }
            }
        }
Ejemplo n.º 24
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;

                                    }
                                //}
                            //}
                       }
                    }
               }
            }
        }
		public static void Descargar(string rfc, string contrasena, string carpeta, DateTime fechaDesde, DateTime fechaHasta, TipoBusqueda busqueda)
		{
			using (IE browser = new IE())
			{
				//limpiar sesion y login 
				browser.ClearCookies();
				Thread.Sleep(1000);

				//java login
				browser.GoTo("https://portalcfdi.facturaelectronica.sat.gob.mx");
				browser.WaitForComplete();

				//entrar por contraseña
				browser.GoTo("https://cfdiau.sat.gob.mx/nidp/app/login?id=SATUPCFDiCon&sid=0&option=credential&sid=0");
				browser.TextField(Find.ByName("Ecom_User_ID")).AppendText(rfc);
				browser.TextField(Find.ByName("Ecom_Password")).AppendText(contrasena);
				browser.Button("submit").Click();

				browser.WaitForComplete();

				//ver si nos pudimos loggear
				if (browser.ContainsText("Login failed, please try again") || browser.ContainsText("La entrada no se ha completado"))
				{
					browser.Close();
					throw new Exception("Los datos de acceso son incorrectos para: " + rfc);
				}

				//seleccionar emitidas o recibidas
				if (busqueda == TipoBusqueda.Emitidas)
				{
					browser.RadioButton("ctl00_MainContent_RdoTipoBusquedaEmisor").Click();
				}
				else
				{
					browser.RadioButton("ctl00_MainContent_RdoTipoBusquedaReceptor").Click();
				}

				browser.Button("ctl00_MainContent_BtnBusqueda").Click();

				Log.Write("Tipo busqueda", Log.Information);

				//Creating the directory if it doesn't exists
				if (!System.IO.Directory.Exists(carpeta))
				{
					System.IO.Directory.CreateDirectory(carpeta);
				}

				//facturas emitidas
				if (busqueda == TipoBusqueda.Emitidas)
				{
					browser.WaitUntilContainsText("Fecha Inicial de Emisión");
					browser.RadioButton("ctl00_MainContent_RdoFechas").Click();
					Thread.Sleep(1000);

					//fecha desde
					browser.TextField("ctl00_MainContent_CldFechaInicial2_Calendario_text").Value = fechaDesde.ToString("dd/MM/yyyy");
					//hasta
					browser.TextField("ctl00_MainContent_CldFechaFinal2_Calendario_text").Value = fechaHasta.ToString("dd/MM/yyyy");
					Thread.Sleep(1000);

					//buscar muchas veces por si marca error de lentitud la pagina del sat >(
					while (true)
					{
						browser.Button("ctl00_MainContent_BtnBusqueda").Click();
						Thread.Sleep(3000);

						if (browser.ContainsText("lentitud"))
						{
							browser.Link("closeBtn").Click();
						}
						else
						{
							break;
						}
					}

					DescargarFacturasListadas(browser, carpeta);
				}
				else
				{
					DateTime mesActual = fechaDesde;
					bool primeraVez = true;

					while (mesActual < fechaHasta)
					{
						browser.WaitUntilContainsText("Fecha de Emisión");
						browser.RadioButton("ctl00_MainContent_RdoFechas").Click();
						Thread.Sleep(1000);

						//seleccionar año adecuado
						browser.SelectList("DdlAnio").SelectByValue(mesActual.Year.ToString());
						//seleccionar mes adecuado
						browser.SelectList("ctl00_MainContent_CldFecha_DdlMes").SelectByValue(mesActual.Month.ToString());

						if (mesActual.Day < 10 && primeraVez)
						{
							//seleccionar dia adecuado
							//click en buscar por que si no no jala
							
							//buscar muchas veces por si marca error de lentitud la pagina del sat >(
							while (true)
							{
								browser.Button("ctl00_MainContent_BtnBusqueda").Click();
								Thread.Sleep(3000);

								if (browser.ContainsText("lentitud"))
								{
									browser.Link("closeBtn").Click();
								}
								else
								{
									break;
								}
							}

							Thread.Sleep(1000);
							primeraVez = false;
						}

						browser.SelectList("ctl00_MainContent_CldFecha_DdlDia").SelectByValue(mesActual.Day.ToString("00"));
						Thread.Sleep(1000);

						//buscar muchas veces por si marca error de lentitud la pagina del sat >(
						while (true)
						{
							browser.Button("ctl00_MainContent_BtnBusqueda").Click();
							Thread.Sleep(3000);

							if (browser.ContainsText("lentitud"))
							{
								browser.Link("closeBtn").Click();
							}
							else
							{
								break;
							}
						}

						DescargarFacturasListadas(browser, carpeta);

						//pasar al siguiente mes
						mesActual = mesActual.AddDays(1);
					}
				}

				browser.Link("ctl00_LnkBtnCierraSesion").Click();
				Thread.Sleep(2000);
				browser.Close();
			}
		}
        public void Login_WithoutUsernameAndPassword_Should_Have_ErrorMessage()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.ContainsText("The User name field is required"));

                Assert.IsTrue(browser.ContainsText("The Password field is required."));
            }
        }
        public void Login_UnSuccessful_Should_Have_Error()
        {
            var browser = new IE();

                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                browser.TextField(Find.ById("UserName")).TypeText("admin");

                browser.TextField(Find.ById("Password")).TypeText("1234");

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.ContainsText("Login was unsuccessful."));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Setups the Test website.
        /// </summary>
        private void SetupWebsite()
        {
            IEInstance = new IE();

            IEInstance.GoTo("{0}install/default.aspx".FormatWith(TestConfig.TestForumUrl));

            IEInstance.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            IEInstance.WaitForComplete(5000);

            // Enter Config Password
            IEInstance.TextField(Find.ById("InstallWizard_txtEnteredPassword")).TypeText(TestConfig.ConfigPassword);
            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepPreviousButton")).Click();

            IEInstance.RadioButton(Find.ById("InstallWizard_rblYAFDatabase_1")).Click();

            // Enter YAF Database Connection
            IEInstance.TextField(Find.ById("InstallWizard_Parameter1_Value")).TypeText(TestConfig.DatabaseServer);

            IEInstance.TextField(Find.ById("InstallWizard_Parameter2_Value")).TypeText(TestConfig.TestDatabase);

            // Test Database Conncection
            IEInstance.Button(Find.ById("InstallWizard_btnTestDBConnection")).Click();

            Assert.IsTrue(IEInstance.ContainsText("Connection Succeeded"), "Database Connection Is Wrong");

            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            // Test Mail Setup
            IEInstance.TextField(Find.ById("InstallWizard_txtTestFromEmail")).TypeText(TestConfig.TestForumMail);

            IEInstance.TextField(Find.ById("InstallWizard_txtTestToEmail")).TypeText("*****@*****.**");

            IEInstance.Button(Find.ById("InstallWizard_btnTestSmtp")).Click();

            Assert.IsTrue(
                IEInstance.ContainsText("Mail Sent. Verify it's received at your entered email address."),
                "Mail Send Failed");

            if (TestConfig.UseTestMailServer)
            {
                SmtpMessage mail = SmtpServer.ReceivedEmail[0];

                Assert.AreEqual("*****@*****.**", mail.ToAddresses[0].ToString(), "Receiver does not match");
                Assert.IsTrue(mail.FromAddress.ToString().Contains(TestConfig.TestForumMail), "Sender does not match");
                Assert.AreEqual(
                    "Test Email From Yet Another Forum.NET", mail.Headers["Subject"], "Subject does not match");

                Assert.AreEqual(
                    "The email sending appears to be working from your YAF installation.",
                    mail.MessageParts[0].BodyView,
                    "Body does not match");
            }

            // Now continue to Initialize Database
            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            // Initialize Database
            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).ClickNoWait();

            IEInstance.WaitUntilContainsText("Create Board", 300);

            Assert.IsTrue(IEInstance.ContainsText("Create Board"));

            // Board Settings
            IEInstance.TextField(Find.ById("InstallWizard_TheForumName")).TypeText(TestConfig.TestApplicationName);
            IEInstance.TextField(Find.ById("InstallWizard_ForumEmailAddress")).TypeText(TestConfig.TestForumMail);

            // Admin User
            IEInstance.TextField(Find.ById("InstallWizard_UserName")).TypeText(TestConfig.AdminUserName);
            IEInstance.TextField(Find.ById("InstallWizard_AdminEmail")).TypeText(TestConfig.TestForumMail);
            IEInstance.TextField(Find.ById("InstallWizard_Password1")).TypeText(TestConfig.AdminPassword);
            IEInstance.TextField(Find.ById("InstallWizard_Password2")).TypeText(TestConfig.AdminPassword);
            IEInstance.TextField(Find.ById("InstallWizard_SecurityQuestion")).TypeText(TestConfig.AdminPassword);
            IEInstance.TextField(Find.ById("InstallWizard_SecurityAnswer")).TypeText(TestConfig.AdminPassword);

            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).ClickNoWait();

            IEInstance.WaitUntilContainsText("Setup/Upgrade Finished", 300);

            Assert.IsTrue(IEInstance.ContainsText("Setup/Upgrade Finished"));

            IEInstance.Button(Find.ById("InstallWizard_FinishNavigationTemplateContainerID_FinishButton")).ClickNoWait();

            IEInstance.WaitUntilContainsText("Welcome Guest!", 300);

            Assert.IsTrue(IEInstance.ContainsText("Welcome Guest!"), "Installation failed");
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Registers the standard test user.
        /// </summary>
        /// <param name="browser">The <paramref name="browser"/> instance.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <returns>
        /// If User was Registered or not
        /// </returns>
        public static bool RegisterStandardTestUser(IE browser, string userName, string password)
        {
            browser.GoTo("{0}yaf_register.aspx".FormatWith(TestConfig.TestForumUrl));

            var email = "{0}@test.com".FormatWith(userName.ToLower());

            browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            // Check if Registrations are Disabled
            if (browser.ContainsText("You tried to enter an area where you didn't have access"))
            {
                return false;
            }

            // Accept the Rules
            if (browser.ContainsText("Forum Rules"))
            {
                browser.Button(Find.ById("forum_ctl04_Login1_LoginButton")).Click();
                browser.Refresh();
            }

            if (browser.ContainsText("Security Image"))
            {
                return false;
            }

            // Fill the Register Page
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_UserName"))).TypeText(
                userName);

            if (browser.ContainsText("Display Name"))
            {
                browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_DisplayName"))).TypeText(userName);
            }

            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Password"))).TypeText(password);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_ConfirmPassword"))).TypeText(password);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Email"))).TypeText(email);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Question"))).TypeText(password);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Answer"))).TypeText(password);

            ////browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_tbCaptcha"))).TypeText(captcha);

            // Create User
            browser.Button(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_StepNextButton"))).Click();

            if (!browser.ContainsText("Forum Preferences"))
            {
                return false;
            }

            browser.Button(Find.ById(new Regex("ProfileNextButton"))).Click();

            return browser.Link(Find.ById(new Regex("_LogOutButton"))).Exists;
        }
Ejemplo n.º 30
0
        private static void RunPageTest(TestSettings settings)
        {
            string url;
            using (var browser = new IE(ConfigurationManager.AppSettings["WebpageTestUrl"]))
            {
                browser.TextField(Find.ById("url")).Value = settings.Url;

                if (!string.IsNullOrEmpty(settings.TestLocation))
                    browser.SelectList(Find.ById("location")).SelectByValue(settings.TestLocation);
                if (!string.IsNullOrEmpty(settings.Browser))
                    browser.SelectList(Find.ById("browser")).SelectByValue(settings.Browser);
                browser.Link(Find.ById("advanced_settings")).ClickNoWait();
                if (!string.IsNullOrEmpty(settings.Speed))
                    browser.SelectList(Find.ById("connection")).SelectByValue(settings.Speed);
                if (settings.IsPrivate)
                    browser.CheckBox(Find.ById("keep_test_private")).Change();

                if (!string.IsNullOrEmpty(settings.Username))
                    browser.TextField(Find.ById("username")).TypeText(settings.Username);
                if (!string.IsNullOrEmpty(settings.Password))
                    browser.TextField(Find.ById("password")).TypeText(settings.Password);

                browser.Button(Find.ByName("submit")).Click();

                browser.WaitUntilContainsText("First View", settings.Timeout);
                if (browser.ContainsText("partially complete"))
                {
                    Thread.Sleep(10000);
                    browser.Refresh();
                }

                browser.WaitUntilContainsText("Raw page data", settings.Timeout);

                url = browser.Link(Find.ByText("Raw page data")).Url;
            }
            var csvRequest = (HttpWebRequest) WebRequest.Create(url);
            csvRequest.Accept = "text/csv";

            var data = new List<PageData>();
            using (var stream = csvRequest.GetResponse().GetResponseStream())
            {
                if (stream != null)
                {
                    using (var reader = new StreamReader(stream))
                    {
                        using (var context = new CsvReader(reader))
                        {
                            while (context.Read())
                            {
                                var counter = data.Count;
                                var item = new PageData();
                                item.EventName = counter == 0 ? "Empty Cache" : "Cached Run " + counter;
                                item.Url = context.GetField<string>(3);
                                item.LoadTime = TimeSpan.FromMilliseconds(context.GetField<int>(4));
                                item.TimeToFirstByte = TimeSpan.FromMilliseconds(context.GetField<int>(5));
                                item.Requests = context.GetField<int>(11);
                                data.Add(item);
                            }
                        }
                    }
                }
            }

            var host = ConfigurationManager.AppSettings["MetricTracking:Host"];
            var port = int.Parse(ConfigurationManager.AppSettings["MetricTracking:Port"]);

            using (var metric = new MetricTracker(host, port))
            {
                foreach (var run in data)
                {
                    Console.WriteLine(run.EventName + "\t" + run.LoadTime);

                    var prefix = settings.Prefix + run.EventName.Replace(" ", string.Empty) + ".";
                    metric.Timing(prefix + "LoadTime", run.LoadTime.TotalMilliseconds);
                    metric.Timing(prefix + "TimeToFirstByte", run.TimeToFirstByte.TotalMilliseconds);
                    metric.Value(prefix + "Requests", run.Requests);
                }
            }
        }