/// <summary>
        /// Logins the user.
        /// </summary>
        /// <param name="browser">The <paramref name="browser"/> instance.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">The user password.</param>
        /// <returns>If User login was successfully or not</returns>
        public static bool LoginUser(IE browser, string userName, string userPassword)
        {
            // Login User
            browser.GoTo("{0}yaf_login.aspx".FormatWith(TestConfig.TestForumUrl));

            // Check If User is already Logged In
            if (browser.Link(Find.ById(new Regex("_LogOutButton"))).Exists)
            {
                browser.Link(Find.ById("forum_ctl01_LogOutButton")).Click();

                browser.Button(Find.ById("forum_ctl02_OkButton")).Click();
            }

            browser.GoTo("{0}yaf_login.aspx".FormatWith(TestConfig.TestForumUrl));

            browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            browser.TextField(Find.ById(new Regex("Login1_UserName"))).TypeText(userName);
            browser.TextField(Find.ById(new Regex("Login1_Password"))).TypeText(userPassword);

            browser.Button(Find.ById(new Regex("LoginButton"))).ClickNoWait();

            browser.GoTo(TestConfig.TestForumUrl);

            return browser.Link(Find.ById(new Regex("LogOutButton"))).Exists;
        }
Beispiel #2
0
        /// <summary>
        /// Screen Scrape Events
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        static List<EventDetail> FetchEvents(string query)
        {
            var eventDetails = new List<EventDetail>();
            using (var _browser = new IE("http://www.gettyimages.com", false))
            {
                _browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide);
                _browser.TextField(Find.ById("txtPhrase")).Clear();
                _browser.TextField(Find.ById("txtPhrase")).TypeText(query);
                var editorialChkfield = _browser.CheckBox(Find.ById("cbxEditorial"));

                if (!editorialChkfield.Checked)
                    editorialChkfield.Click();

                _browser.Button(Find.ById("btnSearch")).Click();

                if (_browser.Link(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_lnkSeeMore")).Exists)
                {
                    _browser.Link(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_lnkSeeMore")).Click();
                    _browser.Div(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_refinementContent")).WaitUntilExists();

                    var filterContentDiv = _browser.Div(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_refinementContent"));

                    foreach (var link in filterContentDiv.Links.Filter(Find.ByClass("refineItem")))
                    {
                        var splitList = link.OuterHtml.Split('\'');

                        if (splitList.Length > 5)
                            eventDetails.Add(new EventDetail() { EventId = int.Parse(splitList[1]), EventName = splitList[5].Trim() });
                    }
                }
            }

            return eventDetails;
        }
Beispiel #3
0
 protected void Login(IE ie)
 {
     TextField tf = ie.TextField(Find.ByName(t => t.EndsWith("$UserName")));
     if (!tf.Exists) return; //already logged
     tf.TypeText("Alkampfer");
     ie.TextField(Find.ByName(t => t.EndsWith("$Password"))).TypeText("12345");
     ie.Button(Find.ByName(b => b.EndsWith("$LoginButton"))).Click();
 }
Beispiel #4
0
 public Browser Authorize(string login, string password)
 {
     Browser browser = new IE("https://www.codeplex.com/site/login");
     
     browser.GoTo("https://www.codeplex.com/site/login");
     browser.Link("CodePlexLogin").Click();
     browser.TextField("UserName").TypeText(login);
     browser.TextField("Password").TypeText(password);
     browser.Button("loginButton").Click();
     
     return browser;
 }
        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();
            }
        }
        public bool Login(string username, string password)
        {
            ie = new IE();

            ie.GoTo("http://www.cruisecontrolnet.org/login");
            if (!AtChiliCCNet()) return false;

            ie.TextField(WatiN.Core.Find.ByName("username")).SetAttributeValue("value", username);

            ie.TextField(WatiN.Core.Find.ByName("password")).SetAttributeValue("value", password);
            ie.Button(WatiN.Core.Find.ByName("login")).Click();

            if (ie.Elements.Exists("password")) return false; // still on logon page, so login failed

            return true;
        }
Beispiel #7
0
        public void TestAlterDescription()
        {
            WatiN.Core.IE window = ie;
            ie.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx");
            base.Login(ie);
            Button btn_ctl00ContentPlac = window.Button(Find.ByName("ctl00$ContentPlaceHolder1$PhotoAlbumManager1$grdPhotoAlbum$ctl04$Button1"));

            Assert.That(btn_ctl00ContentPlac.Exists);
            Span spn_ctl00_ContentPla = window.Span(Find.ById("ctl00_ContentPlaceHolder1_PhotoAlbumManager1_frmEdit_rptPhoto_ctl00_SinglePhotoThumbnail1_lblDescription"));

            Assert.That(spn_ctl00_ContentPla.Exists);
            //Added after the registration
            TextField txt_editCurrent = window.TextField(Find.ById("editCurrent"));

            Assert.That(txt_editCurrent.Exists);
            txt_editCurrent.WaitUntilExists(3000);

            window.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx");

            btn_ctl00ContentPlac.Click();

            spn_ctl00_ContentPla.Click();

            txt_editCurrent.Click();


            txt_editCurrent.AppendText("!!");
            txt_editCurrent.KeyDown('\n');
        }
        public void LocatingThings()
        {
            using (var browser =
                new IE("http://www.pluralsight.com"))
            {
                //// Get a reference to a HTML input element, type=text, id=Name
                //TextField applicantName = browser.TextField(Find.ById("Name"));

                //// Get a reference to a HTML link element with id=HelpLink
                //Link helpHyperlink = browser.Link(Find.ById("HelpLink"));

                //// Get a reference to a HTML input element, type=submit, id=ApplyNow
                //Button applyButton = browser.Button(Find.ById("ApplyNow"));

                //// Get a reference to a HTML paragraph element, id=Name
                //Para nameParagraph = browser.Para(Find.ById("Name"));

            TextField applicantName = browser.TextField(Find.ById("Name"));

            Link helpHyperlink = browser.Link(Find.ById("HelpLink"));

            Button applyButton = browser.Button(Find.ById("ApplyNow"));

            Para nameParagraph = browser.Para(Find.ById("Name"));
            }
        }
        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");
        }
        private void Login(ref IE ie)
        {
            Utilities.NavigateToHomePage(ref ie);

            if (ie.Url.Contains("Login"))
            {
                ie.GoTo(Utilities.GetUrl("Index.aspx"));

                string UserName = ConfigurationReader.getWebUserName();
                string Password = ConfigurationReader.getWebPassword();

                ie.TextField(Find.ById("txtUsername")).TypeText(UserName);
                ie.TextField(Find.ById("txtPassword")).TypeText(Password);

                ie.Image(Find.ById("IbLogin")).ClickNoWait();
            }
        }
        public void SuccessfulAdministrationLogin()
        {
            var browserUrl = string.Empty;
            using (var browser = new IE("http://localhost:1200/"))
            {
                browser.Link(Find.ByText("Admin")).Click();
                browser.TextField(Find.ById("UserName")).TypeText("administrator");
                browser.TextField(Find.ById("Password")).TypeText("password123!");

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

                browserUrl = browser.Url;
            }

            Assert.That(browserUrl.Contains("/StoreManager"), string.Format("Browser Url is incorrect - it is actually {0}", browserUrl));
        }
Beispiel #12
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");
            }
        }
        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"));
            }
        }
Beispiel #14
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));
     }
 } 
        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));
            }
        }
        public void Check_That_When_Logged_In_As_Admin_Then_Add_Product_Works()
        {
            var result = false;
            using (IE netWindow = new IE("http://localhost:49573/default.aspx"))
            {
                LoginAsAdmin(netWindow);

                netWindow.Link(Find.ById("ctl00_ucHeader_lnkAdminPage")).Click();
                #region hidden new way
                netWindow.Link(Find.ById(new Regex("AdminPage$")));
                #endregion

                netWindow.WaitForComplete();

                netWindow.Button(Find.ById("ctl00_ucHeader_lnkProductAdmin")).Click();
                netWindow.WaitForComplete();

                netWindow.Button(Find.ById("ctl00_ContentPlaceHolder1_RadDock1_C_btnAddProduct")).Click();
                netWindow.WaitForComplete();

                netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductName")).TypeText(String.Format("Paul Test Product {0}", DateTime.Now.Ticks.ToString()));
                netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlProductManufacturer")).SelectByValue("3");
                netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlCategoryList")).SelectByValue("2");
                netWindow.WaitForComplete(100);
                netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlSubCategoryList")).SelectByValue("2");
                netWindow.WaitForComplete();
                netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnAddCombo")).Click();
                netWindow.WaitForComplete();
                netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductPrice")).TypeText("19.99");
                netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductModel")).TypeText("Paul Test Model 1");
                netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnSave")).Click();

                netWindow.WaitForComplete();

                Span resultMessage = netWindow.Span(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ucMessage_lblMessage"));
                if (resultMessage.Text == "New Product created successfuly")
                {
                    result = true;
                }
            }
            Assert.IsTrue(result);
        }
        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();
                }
                
            }
        }
Beispiel #18
0
        public static bool IsExist(IE ie, HControl control)
        {
            try
            {
                bool existed = true;
                Regex regex = new Regex(FilterPattern.GetToPattern(control.Value));
                switch (control.Control.ToLower())
                {
                    case ControlType.AHref:
                        existed = ie.Link(Find.ByText(regex)).Exists;
                        break;
                    case ControlType.AHrefNoText:
                        try
                        {

                        }
                        catch (Exception ex)
                        {
                            existed = false;
                        }
                        break;
                    case ControlType.Button:
                        existed = ie.Button(GetControl(ie, control)).Exists;
                        break;
                    case ControlType.Div:
                        existed = ie.Div(GetControl(ie, control)).Exists;
                        break;
                    case ControlType.TextArea:
                        existed = ie.TextField(GetControl(ie, control)).Exists;
                        break;
                    case ControlType.TextBox:
                        existed = ie.TextField(GetControl(ie, control)).Exists;
                        break;
                }
                return existed;// 
            }
            catch (Exception ex)
            {
                return false;
            }
        }
 public ResultWindow(int timeLimit , string idProblem)
     : this()
 {
     this.timeLimit = timeLimit;
     this.idProblem = idProblem;
     Process process = new Process();
     process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
     process.StartInfo.CreateNoWindow = true;
     process.StartInfo.UseShellExecute = false;
     process.StartInfo.FileName = "cmd";
     process.StartInfo.Arguments =
         string.Format("/C \"\"{0}\" < \"{1}\" > \"{2}\"\"",
         Properties.Settings.Default.FileExec,
         Properties.Settings.Default.FileInput,
         Properties.Settings.Default.FileOutput);
     process.Start();
     if (!process.WaitForExit(timeLimit * 1000))
         process.Kill();
     if (process.ExitCode != 0)
     {
         runtime.Visibility = Visibility.Visible;
         return;
     }
     timeExec.Content = process.TotalProcessorTime.Milliseconds / 1000f + "s";
     try
     {
         textInput = File.ReadAllText(Properties.Settings.Default.FileInput);
         textOutput = File.ReadAllText(Properties.Settings.Default.FileOutput);
         textOutput = textOutput.Replace("\r\n", "\n");
         //Settings.MakeNewIeInstanceVisible = false;
         WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false;
         browser = new IE(prefix + idProblem);
         TextField inputField = browser.TextField(Find.ById("edit-input-data"));
         WatiN.Core.Button buttonSubmit = browser.Button(Find.ById("edit-output"));
         inputField.Value = textInput;
         buttonSubmit.Click();
         browser.WaitForComplete();
         string result = browser.Html;
         int begin = result.IndexOf("<pre>") + 5;
         textCorrect = result.Substring(begin, result.IndexOf("</pre>") - begin);
         File.WriteAllText(Properties.Settings.Default.FileCorrect, textCorrect);
         if (textOutput != textCorrect)
             incorrect.Visibility = Visibility.Visible;
         else
             accepted.Visibility = Visibility.Visible;
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     browser.ForceClose();
 }
        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"));
                });
            }
        }
Beispiel #21
0
        public void Register()
        {
            try
            {
                Ie = new IE("about:blank");
                Ie.GoTo("http://localhost/GuestBook/GuestBook.aspx");
                Ie.TextField(Find.ByName("name")).TypeText("Jay");
                Ie.TextField(Find.ByName("comments")).TypeText("Hello");
                Ie.Button(Find.ByName("save")).Click();

                Assert.AreEqual("Jay", Ie.TableCell(Find.By("innerText", "Jay")).Text, @"innerText does not match");
                Assert.AreEqual("Hello", Ie.TableCell(Find.By("innerText", "Hello")).Text, @"innerText does not match");
            }
            finally
            {
                if (Ie != null)
                {
                    InternetExplorer internetExplorer = (InternetExplorer)Ie.InternetExplorer;
                    internetExplorer.Quit();
                }
            }
        }
Beispiel #22
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                IE ie = new IE();

                ie.GoTo("www.terra.com.br");

                ie.WaitForComplete();

                ie.TextField("autocomplete").Value = "esporte";
                ie.TextField("autocomplete").Focus();

                SendKeys.SendWait("{ENTER}");
                //ie.TextField("autocomplete").KeyPress((char)Keys.Enter);

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
        public void Login_Successful_Should_Have_LogOut_Link()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

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

                //browser.Element(x => x.)

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

                browser.TextField(Find.ById("Password")).TypeText("password123!");

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

                Assert.IsTrue(browser.Link(Find.ByText("Log Out")).Exists);

                browser.Link(Find.ByText("Log Out")).Click();

            }
        }
Beispiel #24
0
        public void Should_set_date_in_date_field()
        {
            // GIVEN
            using (var browser = new IE("http://jqueryui.com/demos/datepicker/"))
            {
                var datePicker = browser.Control<DatePicker>("datepicker");
                Assert.IsTrue(datePicker.Enabled, "pre-condition");

                // WHEN
                datePicker.Date = new DateTime(2009, 12, 6);

                // THEN
                Assert.AreEqual("12/06/2009", browser.TextField("datepicker").Text);
            }
        }
Beispiel #25
0
        public void Test()
        {
            // Open a new Internet Explorer window and
            // goto the google website.
            IE ie = new IE("http://www.google.com");

            // Find the search text field and type Watin in it.
            ie.TextField(Find.ByName("q")).TypeText("WatiN");

            // Click the Google search button.
            ie.Button(Find.ByValue("Google Search")).Click();

            // Uncomment the following line if you want to close
            // Internet Explorer and the console window immediately.
            //ie.Close();
        }
        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);

            }
            
        }
Beispiel #27
0
        public void TestWebUIButtonValidation()
        {
            var input = 0;

            string[] Headers = { "All Numbers:",
                                 "All Odd Numbers:",
                                 "All Even Numbers:",
                                 "All Extended FizzBuzzs:",
                                 "All Fibonacci Numbers:" };

            using (var browser = new WatiN.Core.IE(testUrl))
            {
                browser.TextField(Find.ByName("txtNumber")).TypeText(input.ToString());
                browser.Button(Find.ByName("btnGenerate")).Click();
                browser.WaitForComplete();

                Assert.IsTrue(string.IsNullOrWhiteSpace(browser.Divs[0].Text));
            }
        }
        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 ShouldBePossibleToEnumerateListItems()
        {
            // GIVEN searching for WatiN on Google
            using (var ie = new IE("www.google.com"))
            {
                ie.TextField(Find.ByName("q")).TypeText("WatiN");
                ie.Button(Find.ByName("btnG")).Click();

                // WHEN retrieving the results
                var listItems = ie.ElementsOfType<ListItem>();

                // THEN expect 10 results shown
                foreach (var listItem in listItems)
                {
                    Console.WriteLine(listItem.Text);
                    Console.WriteLine();
                }
                Assert.AreEqual(10, listItems.Count);
            }
        }
Beispiel #30
0
        public void WatinOverview()
        {
            using (var ie = new IE())
            {
                ie.BringToFrontForDemo();
                ie.AutoClose = false;

                // Navigate
                ie.GoTo("http://localhost:62988/Register.aspx");

                // Finding a HTML element by id
                var passwordTextBox = ie.TextField(Find.ById("Password"));

                // Typing text
                passwordTextBox.TypeText("Hello World");

                // Clicking a button
                ie.Button(Find.ById("DoRegister")).Click();
            }
        }
        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();
            }
        }
        public void Test_01_NO_CssSelectors()
        {
            using (Browser browser = new IE("http://www.google.com"))
            {
                var searchText = browser.TextField(new AndConstraint(
                        Find.ByName("q"),
                        Find.ByExistenceOfRelatedElement<Element>
                                (e => e.Ancestor<Form>(Find.By("action", "/search")))
                        ));

                Assert.IsNotNull(searchText);
                Assert.IsTrue(searchText.Exists);

                var button = browser.Button(Find.ByClass("lsb"));

                searchText.TypeText("watin");
                button.Click();

                browser.WaitUntilContainsText("pronounced as What-in", 5);
            }
        }
Beispiel #33
0
        public void TestWebUIButton1()
        {
            var input = 123;

            string[] Headers = { "All Numbers:",
                                 "All Odd Numbers:",
                                 "All Even Numbers:",
                                 "All Extended FizzBuzzs:",
                                 "All Fibonacci Numbers:" };

            using (var browser = new WatiN.Core.IE(testUrl))
            {
                browser.TextField(Find.ByName("txtNumber")).TypeText(input.ToString());
                browser.Button(Find.ByName("btnGenerate")).Click();
                browser.WaitForComplete();
                //check each div has content
                var hIdx = 0;

                //sequence objects
                var allNumbers = new AllNumbers();
                var allEven    = new AllEvenNumbers();
                var allOdd     = new AllOddNumbers();
                var allFizz    = new AllExtendedFizzBuzzs();
                var allFib     = new AllFibonacciNumbers();

                foreach (var div in browser.Divs)
                {
                    var h = Headers[hIdx];
                    //check bold txt
                    if (div.Children().Count != 1)
                    {
                        Assert.Fail("Missing or extra bold header of " + h);
                    }
                    else
                    {
                        var boldHeader = div.Children()[0];
                        Assert.IsTrue(boldHeader.OuterHtml.Equals(string.Format("<b>{0}</b>", h)));
                    }

                    switch (hIdx)
                    {
                    case 0:
                        var allNumberSequence = string.Join(", ", allNumbers.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allNumberSequence)));
                        break;

                    case 1:
                        var allOddSequence = string.Join(", ", allOdd.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allOddSequence)));
                        break;

                    case 2:
                        var allEvenSequence = string.Join(", ", allEven.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allEvenSequence)));
                        break;

                    case 3:
                        var allFizzSequence = string.Join(", ", allFizz.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allFizzSequence)));
                        break;

                    case 4:
                        var allFibSequence = string.Join(", ", allFib.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allFibSequence)));
                        break;
                    }
                    hIdx++;
                }
            }
        }