Tester for System.Web.UI.WebControls.Button
Inheritance: AspControlTester
Exemple #1
0
        protected override void SetUp()
        {
            base.SetUp();
            button = new ButtonTester("button", CurrentWebForm);
            disabledButton = new ButtonTester("disabled", CurrentWebForm);
            clickResult = new LabelTester("clickResult", CurrentWebForm);

            Browser.GetPage(BaseUrl + "AspTester/ButtonTestPage.aspx");
        }
        public void CreateAccount()
        {
            // use the ViewAccounts page to create a new account.
            // This shows how to interact with the asp form, but also
            // that testing the ASPX page doesn't have as much value
            // as you might think.

            #region some constants
            const string newName = "Testing Account";
            const string newBalance = "1234";
            #endregion

            #region set up the page

            LoadPage("viewaccounts.aspx");

            TextBoxTester txtName = new TextBoxTester("txtName",
                                                        CurrentWebForm);
            TextBoxTester txtBalance = new TextBoxTester("txtBalance",
                                                        CurrentWebForm);
            ButtonTester btnCreate = new ButtonTester("btnCreate",
                                                        CurrentWebForm);
            #endregion

            #region fill in some data & submit form

            txtName.Text = newName;
            txtBalance.Text = newBalance;

            btnCreate.Click();

            #endregion

            #region Datagrid - did it work?

            // the page has refreshed --
            // see if our new account is in the grid.
            DataGridTester grdAccounts = new DataGridTester(
                                                    "grdAccounts",
                                                    CurrentWebForm);
            // the last row is the newest one:
            DataGridTester.Row newRow = grdAccounts.GetRow(grdAccounts.RowCount - 1);
            // first cell is account id, 2nd is account name
            // name should be the same as the value we just saved...
            Assert("New account wasn't last in the grid",
                newRow.TrimmedCells[1] == newName);

            #endregion

            #region teardown
            // delete the account we just created.
            AccountFactory.DeleteAccount(int.Parse(newRow.TrimmedCells[0]));
            #endregion
        }
Exemple #3
0
		public void TestGoToPageIndex() 
		{ 
			// First, instantiate "Tester" objects: 
			ButtonTester buttonLogin = new ButtonTester("ButtonLogin", CurrentWebForm); 
			ButtonTester button= new ButtonTester("Button", CurrentWebForm); 

			Browser.GetPage("http://localhost/Castle.MVC.Test.Web/Views/index.aspx"); 
			string loginPage = this.Browser.CurrentUrl.AbsoluteUri.ToString();
			buttonLogin.Click(); 
			button.Click();
			string currentPage = this.Browser.CurrentUrl.AbsoluteUri.ToString();
			Assert(currentPage, loginPage.ToLower() == currentPage.ToLower());
		} 
Exemple #4
0
        protected override void SetUp()
        {
            base.SetUp();

            UserControlTester userControl = new UserControlTester("userControl", CurrentWebForm);

            label = new LabelTester("label", userControl);
            button = new ButtonTester("button", userControl);
            linkButton = new LinkButtonTester("linkButton", userControl);

            clickResult = new LabelTester("clickResult", CurrentWebForm);

            Browser.GetPage(BaseUrl + "AspTester/UserControlTestPage.aspx");
        }
Exemple #5
0
		public void TestGoToPage2WithButtonLogin() 
		{ 
			// First, instantiate "Tester" objects: 
			ButtonTester buttonLogin = new ButtonTester("ButtonLogin", CurrentWebForm); 
			LabelTester labelTester = new LabelTester("LabelPreviousView", CurrentWebForm);

			// Second, visit the page being tested: 
			Browser.GetPage("http://localhost/Castle.MVC.Test.Web/Views/index.aspx"); 
			string loginPage = this.Browser.CurrentUrl.AbsoluteUri.ToString();

			buttonLogin.Click(); 
			string currentPage = this.Browser.CurrentUrl.AbsoluteUri.ToString();
			Assert(currentPage, loginPage != currentPage);
			AssertEquals("index", labelTester.Text); 
		} 
Exemple #6
0
        public void TestButtonClickInRepeater()
        {
            ButtonTester button1 = new ButtonTester("Button1", CurrentWebForm);
            LabelTester label1 = new LabelTester("Label1", CurrentWebForm);

            button1.Click();

            ButtonTester innerButton1 = new ButtonTester("btnInner", repeater3.Item(0));
            ButtonTester innerButton2 = new ButtonTester("btnInner", repeater3.Item(1));

            innerButton1.Click();
            Assert.AreEqual("Thing 1", label1.Text);

            innerButton2.Click();
            Assert.AreEqual("Thing 2", label1.Text);
        }
        public void TestDynamicListDefinitionForArticles()
        {
            Console.WriteLine("TestDynamicListDefinitionForArticles");
            //DnaTestURLRequest dnarequest = new DnaTestURLRequest("haveyoursay");
            _dnarequest.SetCurrentUserEditor();
            _dnarequest.UseEditorAuthentication = true;
            string relativePath = @"/dna/haveyoursay/EditDynamicListDefinition";
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);
           
            TextBoxTester name = new TextBoxTester("txtName", CurrentWebForm);
            name.Text = "DynamicListForArticle";

            DropDownListTester type = new DropDownListTester("cmbType", CurrentWebForm);
            ListItemTester item = type.Items.FindByValue("ARTICLES");
            item.Selected = true;

            //Create Dynamic List Definiton by clicking update.
            ButtonTester update = new ButtonTester("btnUpdate", CurrentWebForm);
            update.Click();

            testDynamicListAdmin("DynamicListForArticle");

            string xml;
            int id = 0;
            getDynamicListDefinitionXML("DynamicListForArticle", out xml, out id);
            if (id > 0)
            {
                _dynamicLists.Add(id, "DynamicListForArticle");
            }

            //Validate the Dynamic list Definition Xml.
            DnaXmlValidator validator = new DnaXmlValidator(xml, "DynamicListForArticle.xsd");
            validator.Validate();

            //Bring up the edit page and check it displays the list.
            relativePath = @"/dna/haveyoursay/EditDynamicListDefinition?id=" + id.ToString();
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);

            TextBoxTester checkname = new TextBoxTester("txtName", CurrentWebForm);
            string dlistname = checkname.Text;
            Assert.AreEqual(dlistname, "DynamicListForArticle", "Name does not match");

            //Publish the Dynamic List.
            relativePath = @"/dna/haveyoursay/DynamicListAdmin?activateid=" + id.ToString();
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);

        }
        public void Test01MemberListPage()
        {
            Console.WriteLine("Before Test01MemberListPage");
            _dnarequest.SetCurrentUserEditor();
            _dnarequest.UseEditorAuthentication = true;
            string relativePath = @"/dna/haveyoursay/MemberList";
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);

            TextBoxTester entry = new TextBoxTester("txtEntry", CurrentWebForm);
            Assert.AreEqual(entry.Visible, true);
            entry.Text = "1090558354";

            RadioButtonListTester radiolist = new RadioButtonListTester("rdSearchType");
            Assert.AreEqual(radiolist.Visible, true);
            radiolist.SelectedIndex = 0;

            ButtonTester search = new ButtonTester("Search", CurrentWebForm);

            LabelTester err = new LabelTester("lblError",CurrentWebForm);
            Assert.AreNotEqual("Insufficient permissions - Editor Status Required", err.Text);

            Console.WriteLine("After Test01MemberListPage");
        }
        public void Test05RestrictedUsersListSearchByMostRecentPage()
        {
            try
            {
                DnaTestURLRequest dnaRequest = new DnaTestURLRequest("haveyoursay");
                Console.WriteLine("Before Test05RestrictedUsersListSearchByMostRecentPage");
                dnaRequest.SetCurrentUserEditor();
                dnaRequest.UseEditorAuthentication = true;
                string relativePath = @"/dna/haveyoursay/RestrictedUsers";
                dnaRequest.RequestNUnitASPPage(relativePath, Browser);

                ButtonTester mostRecent = new ButtonTester("btnMostRecent", CurrentWebForm);
                mostRecent.Click();

                HtmlTableTester table = new HtmlTableTester("tblResults");

                bool isdata = true;
                if (table.BodyNoTags != "No data for those details")
                {
                    isdata = false;
                }

                Assert.IsTrue(isdata, "No data for Most Recent accounts is returned when there should be at least one.");

                Console.WriteLine("After Test05RestrictedUsersListSearchByMostRecentPage");
            }
            catch (Exception ex)
            {
                Console.WriteLine("EXCEPTION");
                Console.WriteLine(ex.Message);
            }
        }
        public void Test04RestrictedUserListPageSearchByBeginsWithLetterTest()
        {
            try
            {
                DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2");
                Console.WriteLine("Before Test04RestrictedUserListPageSearchByBeginsWithLetterTest");
                dnaRequest.SetCurrentUserEditor();
                dnaRequest.UseEditorAuthentication = true;
                string relativePath = @"/dna/h2g2/RestrictedUsers";
                dnaRequest.RequestNUnitASPPage(relativePath, Browser);

                System.Threading.Thread.Sleep(2000);

                DropDownListTester siteList = new DropDownListTester("SiteList");
                Assert.AreEqual(siteList.Visible, true);
                siteList.Items.FindByText("All").Selected = true;

                DropDownListTester userStatusTypes = new DropDownListTester("UserStatusTypes");
                Assert.AreEqual(userStatusTypes.Visible, true);
                userStatusTypes.Items.FindByText("Both").Selected = true;

                Console.WriteLine("Before Button creation");
                ButtonTester btnD = new ButtonTester("btnD", CurrentWebForm);
                Console.WriteLine("Before Button click");
                btnD.Click();

                System.Threading.Thread.Sleep(2000);

                Console.WriteLine("Before get table");

                HtmlTableTester table = new HtmlTableTester("tblResults");

                bool isdata = true;
                if (table.BodyNoTags != "No data for those details")
                {
                    isdata = false;
                }

                Console.WriteLine("After get table");

                Assert.IsTrue(isdata, "No data for All accounts is returned when there should be at least one.");

                Console.WriteLine("After Test04RestrictedUserListPageSearchByBeginsWithLetterTest");
            }
            catch (Exception ex)
            {
                Console.WriteLine("EXCEPTION");
                Console.WriteLine(ex.Message);
            }
        }
Exemple #11
0
        private void RunTest()
        {
            TextBoxTester textBox1 = new TextBoxTester("textBox1", CurrentWebForm);
            TextBoxTester textBox2 = new TextBoxTester("textBox2", CurrentWebForm);
            TextBoxTester textBox3 = new TextBoxTester("textBox3", CurrentWebForm);
            TextBoxTester textBox4 = new TextBoxTester("textBox4", CurrentWebForm);
            TextBoxTester textBox5 = new TextBoxTester("textBox5", CurrentWebForm);
            ButtonTester button = new ButtonTester("button", CurrentWebForm);

            Browser.GetPage(BaseUrl + "PerformanceTestPage.aspx");
            AssertEquals("textBox1", "textBox1", textBox1.Text);
            AssertEquals("textBox2", "textBox2", textBox2.Text);
            AssertEquals("textBox3", "textBox3", textBox3.Text);
            AssertEquals("textBox4", "textBox4", textBox4.Text);
            AssertEquals("textBox5", "textBox5", textBox5.Text);

            textBox1.Text = "not 1";
            textBox2.Text = "not 2";
            textBox3.Text = "not 3";
            textBox4.Text = "not 4";
            textBox5.Text = "not 5";

            button.Click();
            AssertEquals("textBox1", "not 1", textBox1.Text);
            AssertEquals("textBox2", "not 2", textBox2.Text);
            AssertEquals("textBox3", "not 3", textBox3.Text);
            AssertEquals("textBox4", "not 4", textBox4.Text);
            AssertEquals("textBox5", "not 5", textBox5.Text);
        }
        public void Test05MemberListSearchByEmailPage()
        {
            Console.WriteLine("Before Test05MemberListSearchByEmailPage");
            _dnarequest.SetCurrentUserEditor();
            
            _dnarequest.UseEditorAuthentication = true;
            string relativePath = @"/dna/haveyoursay/MemberList";
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);
            CurrentWebForm.Variables.Add("d_identityuserid", "dotneteditor");

            TextBoxTester entry = new TextBoxTester("txtEntry", CurrentWebForm);
            Assert.AreEqual(entry.Visible, true);
            entry.Text = "*****@*****.**";

            RadioButtonListTester radiolist = new RadioButtonListTester("rdSearchType", CurrentWebForm);
            Assert.AreEqual(radiolist.Visible, true);
            
            int index = GetSelectedIndex(radiolist, "Email");

            radiolist.SelectedIndex = index;

            ButtonTester search = new ButtonTester("Search", CurrentWebForm);
            search.Click();

            HtmlTableTester table = new HtmlTableTester("tblResults");

            bool found = false;
            if (table.BodyNoTags != "No data for those details")
            {
                for (int i = 1; i < table.Rows.Length; i++)
                {
                    HtmlTagTester htmltag = (HtmlTagTester)table.Rows[i].Children("td").GetValue(1);
                    string userID = htmltag.InnerHtml;

                    string testSuperUserIDLink = "<a href=\"/dna/moderation/MemberDetails?userid=" + testSuperUserID.ToString() + "\">U" + testSuperUserID.ToString() + "</a>";

                    if (userID == testSuperUserIDLink)
                    {
                        found = true;
                    }
                }
                Assert.IsTrue(found, "User " + testSuperUserID.ToString() + ": Not returned and displayed in Member List Page.");
            }
            else
            {
                Assert.IsTrue(false, "Error no results returned.");
            }
 
            Console.WriteLine("After Test05MemberListSearchByEmailPage");
        }
Exemple #13
0
 protected override void SetUp()
 {
     multiline = new TextBoxTester("MultiLineTextBox", CurrentWebForm);
     doPostBack = new ButtonTester("DoPostBackButton", CurrentWebForm);
     Browser.GetPage(BaseUrl + "MultiLineTextInput.aspx");
 }
Exemple #14
0
        /// <summary>
        /// Executed before each test method is run.  Override in subclasses to do subclass
        /// set up.  NOTE: [SetUp] attribute cannot be used in subclasses because it is already
        /// in use.
        /// </summary>
        protected override void SetUp()
        {
            PostBtn = new ButtonTester("PostBtn", CurrentWebForm);
            SaveBtn = new ButtonTester("SaveBtn", CurrentWebForm);
             NewBtn = new ButtonTester("NewBtn", CurrentWebForm);
             EditBtn = new ButtonTester("EditBtn", CurrentWebForm);
             DelBtn = new ButtonTester("DelBtn", CurrentWebForm);
            IdTb = new TextBoxTester("IdTb", CurrentWebForm);

            sessionLbl = new LabelTester("SessionLbl", CurrentWebForm);

            Powiat = new TextBoxTester("ctl02_PowiatEdit", CurrentWebForm);
            Kod = new TextBoxTester("ctl02_KodEdit", CurrentWebForm);
            Gus = new TextBoxTester("ctl02_GusEdit", CurrentWebForm);
            Kraj = new TextBoxTester("ctl02_KrajEdit", CurrentWebForm);
            Ulica = new TextBoxTester("ctl02_UlicaEdit", CurrentWebForm);
            Gmina = new TextBoxTester("ctl02_GminaEdit", CurrentWebForm);
            Wojewodztwo = new TextBoxTester("ctl02_WojewodztwoEdit", CurrentWebForm);
            Poczta = new TextBoxTester("ctl02_PocztaEdit", CurrentWebForm);
            Miejscowosc = new TextBoxTester("ctl02_MiejscowoscEdit", CurrentWebForm);

            PowiatLbl = new LabelTester("ctl02_Powiat", CurrentWebForm);
            KodLbl = new LabelTester("ctl02_Kod", CurrentWebForm);
            GusLbl = new LabelTester("ctl02_Gus", CurrentWebForm);
            KrajLbl = new LabelTester("ctl02_Kraj", CurrentWebForm);
            UlicaLbl = new LabelTester("ctl02_Ulica", CurrentWebForm);
            GminaLbl = new LabelTester("ctl02_Gmina", CurrentWebForm);
            WojewodztwoLbl = new LabelTester("ctl02_Wojewodztwo", CurrentWebForm);
            PocztaLbl = new LabelTester("ctl02_Poczta", CurrentWebForm);
            MiejscowoscLbl = new LabelTester("ctl02_Miejscowosc", CurrentWebForm);
            base.SetUp();
        }
        protected override void SetUp()
        {
            button = new ButtonTester("LokalizacjaGrid_SearchBtn", CurrentWebForm);
            filterValue = new TextBoxTester("LokalizacjaGrid_ValueTxt", CurrentWebForm);
            next = new MyLinkTester("Next", CurrentWebForm);
            prev = new MyLinkTester("Prev", CurrentWebForm);
            last = new MyLinkTester("Last", CurrentWebForm);
            first = new MyLinkTester("First", CurrentWebForm);
            //            itemsCount = new LabelTester("ItemsCount", CurrentWebForm);
            currentPage = new LabelTester("CurrentPage", CurrentWebForm);
            filterField = new DropDownListTester("LokalizacjaGrid_FilterList", CurrentWebForm);

            Dm.DeleteSql<Lokalizacja>("Nazwa like 'SSS%'");
            Lokalizacja l1;
            for (int i = 0; i < 80; i++)
            {
                l1 = Lokalizacja.GetWellKnown();
                l1.Nazwa = "SSS" + i.ToString().PadLeft(3, '0');
                l1.Skrot = "LP" + i.ToString().PadLeft(3, '0');

                l1.Save(null);
            }

            base.SetUp();
        }
        public void CreateAccountWithBadInput()
        {
            // an example of a better test --
            // Users report that if you press the Create button without
            // entering appropriate values, the page gives an error instead
            // of dealing with things gracefully.
            //
            // we fix the problem using validators and need to make sure the
            // problem doesn't occur in the future.

            Browser.GetPage("http://localhost/UnitTester/ViewAccounts.aspx");

            // no input given -- should be dealt with gracefully.
            // (not with an error)
            ButtonTester btnCreate = new ButtonTester("btnCreate",
                                                        CurrentWebForm);
            btnCreate.Click();
        }
        protected override void SetUp()
        {
            base.SetUp();
            Browser.GetPage(BaseUrl + "AspTester/ValidationSummaryTestPage.aspx");

            textBox1 = new TextBoxTester("textbox1", CurrentWebForm);
            textBox2 = new TextBoxTester("textbox2", CurrentWebForm);
            textBox3 = new TextBoxTester("textbox3", CurrentWebForm);

            bulletedSummary = new ValidationSummaryTester("bulletedSummary", CurrentWebForm);
            listSummary = new ValidationSummaryTester("listSummary", CurrentWebForm);
            button = new ButtonTester("submit", CurrentWebForm);
        }
        public void TransferAfterSetResult()
        {
            TextBoxTester name = new TextBoxTester("name", CurrentWebForm);
            ButtonTester save = new ButtonTester("save", CurrentWebForm);

            Browser.GetPage("asptest://localhost/TransferAfterSetResult.aspx");
            // Note, that page TransferAfterSetResultSave.aspx has 'EnableViewStateMac="false"'
            // otherwise ViewState validation will fail on a Server.Transfer during a Postback!
            save.Click();
            string result = Browser.CurrentPageText;
            Assert.AreEqual("OK", result);
        }
Exemple #19
0
        protected override void SetUp()
        {
            textBox = new TextBoxTester("textBox", CurrentWebForm);
            multiline = new TextBoxTester("multiline", CurrentWebForm);
            disabled = new TextBoxTester("disabled", CurrentWebForm);
            postback = new ButtonTester("postback", CurrentWebForm);

            Browser.GetPage(BaseUrl + "AspTester/TextBoxTestPage.aspx");
        }
Exemple #20
0
        protected override void SetUp()
        {
            base.SetUp();

            Browser.GetPage(BaseUrl + "/AspTester/ValidatorTestPage.aspx");

            btnSubmit = new ButtonTester("btnSubmit", CurrentWebForm);
        }
        public void Test08MemberListSearchByBBCUIDPage()
        {
            Console.WriteLine("Before Test08MemberListSearchByBBCUIDPage");
            _dnarequest.SetCurrentUserEditor();
            _dnarequest.UseEditorAuthentication = true;
            string relativePath = @"/dna/haveyoursay/MemberList";
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);

            TextBoxTester entry = new TextBoxTester("txtEntry", CurrentWebForm);
            Assert.AreEqual(entry.Visible, true);
            entry.Text = "47C7CDBE-9D79-1517-50CA-0003BA0B17ED";

            RadioButtonListTester radiolist = new RadioButtonListTester("rdSearchType", CurrentWebForm);
            Assert.AreEqual(radiolist.Visible, true);

            int index = GetSelectedIndex(radiolist, "BBCUID");

            radiolist.SelectedIndex = index;

            ButtonTester search = new ButtonTester("Search", CurrentWebForm);
            search.Click();

            Console.WriteLine("After Test08MemberListSearchByBBCUIDPage");
        }
Exemple #22
0
        public void TestSelectedIndexChangedEvent_WhenItemAddedToList()
        {
            ButtonTester addItem = new ButtonTester("add", CurrentWebForm);

            autoPostBack.Checked = true;
            Submit.Click();
            addItem.Click();
            AssertEquals("No", indexChanged.Text);
        }
        protected override void SetUp()
        {
            PostBtn = new ButtonTester("PostBtn", CurrentWebForm);
            NewBtn = new ButtonTester("NewBtn", CurrentWebForm);
            EditBtn = new ButtonTester("EditBtn", CurrentWebForm);
            DelBtn = new ButtonTester("DelBtn", CurrentWebForm);
            SaveBtn = new ButtonTester("SaveBtn", CurrentWebForm);
            CancelBtn = new ButtonTester("CancelBtn", CurrentWebForm);
            IdTb = new TextBoxTester("IdTb", CurrentWebForm);
            sessionLbl = new LabelTester("SessionLbl", CurrentWebForm);

            base.SetUp();
        }
Exemple #24
0
        protected override void SetUp()
        {
            button=new ButtonTester("WniosekList1_SearchBtn", CurrentWebForm);
            filterValue = new TextBoxTester("WniosekList1_ValueTxt", CurrentWebForm);
            next = new MyLinkTester("Next", CurrentWebForm);
            prev = new MyLinkTester("Prev", CurrentWebForm);
            last = new MyLinkTester("Last", CurrentWebForm);
            first = new MyLinkTester("First", CurrentWebForm);
            itemsCount = new LabelTester("ItemsCount", CurrentWebForm);
            currentPage = new LabelTester("CurrentPage", CurrentWebForm);
            filterField = new DropDownListTester("WniosekList1_FilterList", CurrentWebForm);
            Dm.DeleteSql<Wniosek>("Sygnatura like 'SS%'");
            Wniosek w1;
            for (int i = 0; i < 80; i++)
            {
                w1 = Wniosek.GetWellKnown("olo", DateTime.Now);
                w1.Sygnatura = "SS" + i.ToString().PadLeft(3, '0');
                w1.Wnioskodawca.Pesel = "WP" + i.ToString().PadLeft(3, '0');
                w1.Wnioskodawca.Nazwisko = "WN" + i.ToString().PadLeft(3, '0');
                w1.Stypendysta.Pesel = "SP" + i.ToString().PadLeft(3, '0');
                w1.Stypendysta.Nazwisko = "SN" + i.ToString().PadLeft(3, '0');

                w1.Save(null);
            }
            base.SetUp();
        }