Exemple #1
0
        public void AlphabeticalOrderGeoZonesPage()
        {
            Login();
            driver.Url = "http://localhost/litecart/admin/?app=geo_zones&doc=geo_zones";
            ReadOnlyCollection <IWebElement> rows = driver.FindElements(By.CssSelector(".row"));
            List <CountryData> countries          = new List <CountryData>();

            for (int i = 0; i < rows.Count; i++)
            {
                IWebElement countryRow = rows[i];
                ReadOnlyCollection <IWebElement> columns = countryRow.FindElements(By.CssSelector("td"));
                CountryData newCountry = new CountryData(columns[2].GetAttribute("textContent"));
                newCountry.Link = columns[2].FindElement(By.CssSelector("a")).GetAttribute("href");
                countries.Add(newCountry);
            }
            foreach (CountryData country in countries)
            {
                driver.Url = country.Link;
                ReadOnlyCollection <IWebElement> zones = driver.FindElements(By.CssSelector("#table-zones tr"));
                List <string> zonesList       = new List <string>();
                List <string> zonesListSorted = new List <string>();
                for (int i = 1; i < zones.Count - 1; i++)
                {
                    string zoneSelected = zones[i].FindElements(By.CssSelector("td"))[2]
                                          .FindElement(By.CssSelector("[selected]")).GetAttribute("textContent");
                    zonesList.Add(zoneSelected);
                    zonesListSorted.Add(zoneSelected);
                }
                zonesListSorted.Sort();
                for (int i = 0; i < zonesList.Count; i++)
                {
                    Assert.IsTrue(zonesList[i] == zonesListSorted[i]);
                }
            }
        }
Exemple #2
0
        public void AlphabeticalOrder_1()
        {
            Login();

            driver.Url = "http://localhost/litecart/admin/?app=countries&doc=countries";
            ReadOnlyCollection <IWebElement> rows = driver.FindElements(By.CssSelector(".row"));
            List <CountryData> countries          = new List <CountryData>();

            for (int i = 0; i < rows.Count; i++)
            {
                IWebElement countryRow = rows[i];
                ReadOnlyCollection <IWebElement> columns = countryRow.FindElements(By.CssSelector("td"));
                CountryData newCountry = new CountryData(columns[4].GetAttribute("textContent"));
                newCountry.Code       = columns[3].GetAttribute("textContent");
                newCountry.ZonesCount = int.Parse(columns[5].GetAttribute("textContent"));
                newCountry.Link       = columns[4].FindElement(By.CssSelector("a")).GetAttribute("href");
                countries.Add(newCountry);
            }
            List <CountryData> countriesOrdered = new List <CountryData>();

            for (int i = 0; i < countries.Count; i++)
            {
                countriesOrdered.Add(countries[i]);
            }
            countriesOrdered.Sort();
            for (int i = 0; i < countries.Count; i++)
            {
                Assert.True(countries[i] == countriesOrdered[i]);
            }

            foreach (CountryData country in countries)
            {
                if (country.ZonesCount != 0)
                {
                    driver.Url = country.Link;
                    ReadOnlyCollection <IWebElement> zonesTable = driver.FindElements(By.CssSelector("#table-zones tr"));
                    List <string> zonesSorted = new List <string>();
                    for (int i = 1; i < zonesTable.Count - 1; i++) //first element with index == 0 is header and we skip it. last element contents input fields for new zone
                    {
                        string zoneName = zonesTable[i].FindElements(By.CssSelector("td"))[2].GetAttribute("textContent");
                        country.Zones.Add(zoneName);
                        zonesSorted.Add(zoneName);
                    }
                    Assert.IsTrue(country.ZonesCount == country.Zones.Count);
                    zonesSorted.Sort();
                    for (int i = 0; i < zonesSorted.Count; i++)
                    {
                        Assert.IsTrue(zonesSorted[i] == country.Zones[i]);
                    }
                }
            }
        }