public void TestTask9_1() { IList <IWebElement> allCountriesRows; List <string> allCountriesNames = new List <string>(); List <string> allCountriesTemplate = new List <string>(); IList <string> linksForCountryWithTimeZones = new List <string>(); IList <IWebElement> allZoneRows; List <string> allZonesForCurrentCountry = new List <string>(); List <string> allZonesForCurrentCountryTemplate = new List <string>();; IWebElement element; HelperLogin.LogInAdmin(driver); driver.Navigate().GoToUrl("http://localhost/litecart/admin/?app=countries&doc=countries"); //Get all rows with country names allCountriesRows = driver.FindElements(By.CssSelector("[name=countries_form] tr.row")); foreach (IWebElement row in allCountriesRows) { //Get name of each country and link to edit page if country has zones > 0. element = row.FindElement(By.CssSelector("a")); allCountriesNames.Add(element.Text); if (!row.FindElement(By.CssSelector("td:nth-of-type(6)")).Text.Equals("0")) { linksForCountryWithTimeZones.Add(element.GetAttribute("href")); } } //Check sort for Countries allCountriesTemplate.AddRange(allCountriesNames); allCountriesTemplate.Sort(); Assert.IsTrue(allCountriesNames.SequenceEqual(allCountriesTemplate)); //Check sort of Zones foreach (string url in linksForCountryWithTimeZones) { driver.Navigate().GoToUrl(url); allZoneRows = driver.FindElements(By.XPath("//table[@id = 'table-zones'] // input[contains(@name, '[name]') and @type='hidden']")); //Get zone names and check sort foreach (IWebElement zone in allZoneRows) { allZonesForCurrentCountry.Add(zone.GetAttribute("value")); } allZonesForCurrentCountryTemplate.AddRange(allZonesForCurrentCountry); allZonesForCurrentCountryTemplate.Sort(); Assert.IsTrue(allZonesForCurrentCountry.SequenceEqual(allZonesForCurrentCountryTemplate)); allZonesForCurrentCountryTemplate.Clear(); allZonesForCurrentCountry.Clear(); } }
public void TestTask9_2() { IList <IWebElement> allGeoZones; IList <IWebElement> allZonesRowsEditMode; List <string> allZones = new List <string>(); List <string> allZonesTemplate = new List <string>(); List <string> allCountriesUrls = new List <string>(); HelperLogin.LogInAdmin(driver); driver.Navigate().GoToUrl("http://localhost/litecart/admin/?app=geo_zones&doc=geo_zones"); //Get all links to each GeoZone edit page allGeoZones = driver.FindElements(By.CssSelector("[name=geo_zones_form] a[title]")); foreach (IWebElement zone in allGeoZones) { allCountriesUrls.Add(zone.GetAttribute("href")); } //Check sort for each GeoZones foreach (string url in allCountriesUrls) { driver.Navigate().GoToUrl(url); allZonesRowsEditMode = driver.FindElements(By.CssSelector("#table-zones td:nth-child(3) [selected]")); foreach (IWebElement row in allZonesRowsEditMode) { allZones.Add(row.Text); } allZonesTemplate.AddRange(allZones); allZonesTemplate.Sort(); Assert.IsTrue(allZones.SequenceEqual(allZonesTemplate)); allZonesTemplate.Clear(); allZones.Clear(); } }