Tester for System.Web.UI.WebControls.DropDownList
Inheritance: ListControlTester
Example #1
0
        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 Test01RestrictedUsersListPage()
        {
            try
            {
                DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2");
                Console.WriteLine("Before Test01RestrictedUsersListPage");
                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("Premoderated").Selected = true;

                LabelTester error = new LabelTester("lblError");
                string errorText = error.Text;
                bool noError = true;
                if (errorText == "Insufficient permissions - Editor Status Required")
                {
                    noError = false;
                }

                Assert.IsTrue(noError, "Error in Restricted User Page.");

                Console.WriteLine("After Test01RestrictedUsersListPage");
            }
            catch (Exception ex)
            {
                Console.WriteLine("EXCEPTION");
                Console.WriteLine(ex.Message);
            }

        }
        public static void SetData(Stypendysta s, string prefix, WebForm currentWebForm)
        {
            TextBoxTester imie = new TextBoxTester(GetCtrlId(prefix, "ImieEdit"), currentWebForm);
            TextBoxTester imie2 = new TextBoxTester(GetCtrlId(prefix, "Imie2Edit"), currentWebForm);
            TextBoxTester nazwisko = new TextBoxTester(GetCtrlId(prefix, "NazwiskoEdit"), currentWebForm);
            TextBoxTester pesel = new TextBoxTester(GetCtrlId(prefix, "PeselEdit"), currentWebForm);
            TextBoxTester nip = new TextBoxTester(GetCtrlId(prefix, "NipEdit"), currentWebForm);
            DropDownListTester szkola = new DropDownListTester(GetCtrlId(prefix, "SzkolaEdit"), currentWebForm);
            LabelTester uzytkownikWprowadzajacy = new LabelTester(GetCtrlId(prefix, "UzytkownikWprowadzajacyEdit"), currentWebForm);
            LabelTester dataWprowadzenia = new LabelTester(GetCtrlId(prefix, "DataWprowadzeniaEdit"), currentWebForm);

            imie.Text = s.Imie;
            imie2.Text = s.Imie2;
            nazwisko.Text = s.Nazwisko;
            pesel.Text = s.Pesel;
            nip.Text = s.Nip;
            szkola.SelectedValue = s.Szkola.Id.ToString();
            //uzytkownikWprowadzajacy.Text = s.UzytkownikWprowadzajacy;
            //dataWprowadzenia.Text = s.DataWprowadzenia.ToString();

            AdresComponentTest.SetData(s.AdresZameldowania, prefix + "_ctl01", currentWebForm);
            KontaktComponentTest.SetData(s.Kontakt, prefix + "_ctl00", currentWebForm);
        }
        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);
            }
        }
Example #5
0
        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();
        }
Example #6
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();
        }