Пример #1
1
        /// <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;
        }
Пример #2
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"));
            }
        }
Пример #4
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;
        }
        public void Should_add_three_visits()
        {
            new DatabaseTester().Clean();

            var url = "http://localhost:1234/";
            using (var ie = new IE(url))
            {
                ie.Button("submit").Click();
                Thread.Sleep(2000);
                ie.Button("submit").Click();
                Thread.Sleep(2000);
                ie.Button("submit").Click();
                Thread.Sleep(2000);

                ie.ElementsWithTag("hr").Count.ShouldEqual(3);
            }
        }
Пример #6
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();
 }
Пример #7
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"));
            }
        }
Пример #8
0
 public void ClickMe()
 {
     IE ie = new IE("http://localhost/AnthemNxt.Tests/ButtonsAndLabels.aspx");
     Assert.Null(ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text);
     ie.Button(Find.ByName("ctl00$ContentPlaceHolder$button")).Click();
     Assert.NotEqual("", ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text);
     // TODO: Check no postback occurred - how can we do this?
     ie.Close();
 }
Пример #9
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));
            }
        }
Пример #10
0
        public void UploadImage(IE ie, string filePath)
        {
            ie.Link(Find.ById("uploadImage")).Click();

            var fu = ie.FileUpload(Find.ByClass("ImageUpload"));
            fu.Set(filePath);

            ie.Button(Find.ById("ctl00_cphAdmin_btnUploadImage")).Click();
            ie.WaitForComplete();
        }
Пример #11
0
        public void UploadVideo(IE ie, string filePath)
        {
            ie.Link(Find.ById("uploadVideo")).Click();

            var fu = ie.FileUpload(Find.ById("ctl00_cphAdmin_txtUploadVideo"));
            fu.Set(filePath);

            ie.Button(Find.ById("ctl00_cphAdmin_btnUploadVideo")).Click();
            ie.WaitForComplete();
        }
Пример #12
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));
     }
 } 
Пример #13
0
        public void FillUS()
        {
            using (var browser = new IE("http://www.eaa.org/eaa/eaa-membership/eaa-aircraft-insurance-plans/aircraft-insurance/insurance-submit-us"))
            {
                browser.AutoClose = false;

                USPopulatePersonalInfoPage(browser);
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StartNavigationTemplateContainerID_StartNextButton")).Click();

                USPopulateAircraftPage(browser, "1");
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

                // Add another aircraft
                browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraftList_lnkAircraftAdd")).Click();

                USPopulateAircraftPage(browser, "2");
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraft_AddButton")).Click();

                // Add another aircraft
                browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraftList_lnkAircraftAdd")).Click();

                USPopulateAircraftPage(browser, "3");
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraft_AddButton")).Click();

                //
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

                USPopulatePilotPage(browser, "1");
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

                browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilotList_lnkPilotAdd")).Click();
                USPopulatePilotPage(browser, "2");
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilot_AddButton")).Click();

                browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilotList_lnkPilotAdd")).Click();
                USPopulatePilotPage(browser, "3");
                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilot_AddButton")).Click();

                browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            }
        }
        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);
        }
Пример #15
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;
 }
Пример #16
0
 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"));
                });
            }
        }
Пример #18
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();
            }
        }
Пример #19
0
        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;
        }
Пример #20
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 FilterByCategory()
        {
            using (var ie = new IE("http://dc2011.localhost/Project List.aspx"))
            {
                var articles = ie.List(list => list.Parent.ClassName == "list");
                var count = articles.Children().Count;

                ie.SelectList(list => list.Parent.ClassName == "filter").Select("Date Code");
                ie.Button(button => button.Parent.ClassName == "buttons").Click();

                articles.Refresh();
                var filterCount = articles.Children().Count;

                Assert.Less(filterCount, count);
            }
        }
Пример #22
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 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);

            }
            
        }
        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();
            }
        }
Пример #25
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));
            }
        }
Пример #26
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();
                }
                
            }
        }
Пример #27
0
        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);
            }
        }
Пример #28
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();
            }
        }
Пример #29
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 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();
            }
        }
Пример #31
0
        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);
            }
        }
Пример #32
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++;
                }
            }
        }
Пример #33
-1
        public string PassportCheck()
        {
            string strreturn = "";
            using (var browser = new IE("https://www.world-check.com/portal/mod_perl/Login/"))
            {
                if (Find.ByName("username"))
                {
                    browser.TextField(Find.ByName("username")).TypeText("nzrbrt0002");
                    browser.TextField(Find.ByName("password")).TypeText("Go8ahE5s");
                    browser.Image(Find.ByName("submitted")).Click();
                }

                browser.GoTo("https://www.world-check.com/portal/mod_perl/PassportCheck");

                browser.TextField(Find.ByName("givenName")).TypeText("Jim");
                browser.TextField(Find.ByName("lastName")).TypeText("Smith");
                browser.RadioButton(Find.ByName("sexg") && Find.ByValue("M")).Click();
                browser.Span(Find.ById("issuingState-CAN")).Click();
                browser.TextField(Find.ByName("dateOfBirthDay")).TypeText("29");
                browser.TextField(Find.ByName("dateOfBirthMonth")).TypeText("05");
                browser.TextField(Find.ByName("dateOfBirthYear")).TypeText("1978");
                browser.TextField(Find.ByName("passportNumber")).TypeText("WL745488");
                browser.TextField(Find.ByName("expireDateDay")).TypeText("10");
                browser.TextField(Find.ByName("expireDateMonth")).TypeText("07");
                browser.TextField(Find.ByName("expireDateYear")).TypeText("2014");
                browser.Button(Find.ByValue("VERIFY")).Click();

                var element = browser.Element(Find.ByClass("tablelinespacer"));
                var firsttd = element.NextSibling.NextSibling;
                strreturn = firsttd.Text.Replace("Lower Line:","");
                //Assert.IsTrue(browser.ContainsText("WatiN"));
            }
            return strreturn;
        }