public void CountrySortingTest()
        {
            AdminHomePage homePage = LoginPage.LoginToAdmin();

            homePage.GoToCountries();

            // verify that countries have orrect order
            var listOfCountriesForSorting = homePage.GetAllCountries();

            listOfCountriesForSorting.Sort();
            var listOfCountriesUnsorted = homePage.GetAllCountries();

            Assert.AreEqual(listOfCountriesForSorting, listOfCountriesUnsorted);

            var listOfCountriesNames = new List <string>();
            var listOfZonesIndex     = new List <string>();

            var rowsFull = driver.FindElements(By.CssSelector(".dataTable .row"));

            foreach (var webElement in rowsFull)
            {
                listOfCountriesNames.Add(webElement.FindElement(By.CssSelector("td:nth-of-type(5) a")).GetAttribute("innerText"));
                listOfZonesIndex.Add(webElement.FindElement(By.CssSelector("td:nth-of-type(6)")).Text);
            }

//            var listOfZoneIndexes = listOfZones.Select((s,i) =>new{s,i}).Where(p => p.s != "0").Select(p=>p.i).ToList();

            var listOfIndexesWithZones = new List <int>(); // above string doing same sorting

            for (int i = 0; i < listOfZonesIndex.Count; i++)
            {
                if (listOfZonesIndex[i] != "0")
                {
                    listOfIndexesWithZones.Add(i);
                }
            }

            // find countries with zones
            var listOfCountriesWithZones = new List <string>();

            for (int i = 0; i < listOfIndexesWithZones.Count; i++)
            {
                listOfCountriesWithZones.Add(listOfCountriesNames[listOfIndexesWithZones[i]]);
            }

            // verify that zones for every counrty have correct order of zones
            foreach (var country in listOfCountriesWithZones)
            {
                driver.FindElement(By.XPath(".//*[@class='dataTable']//a[text()='" + country + "']")).Click();
                var listOfSybZonesForSorting = homePage.GetAllZonesFromSubZones();
                listOfSybZonesForSorting.Sort();
                var listOfSybZonesUnsorted = homePage.GetAllZonesFromSubZones();

                Assert.AreEqual(listOfSybZonesForSorting, listOfSybZonesUnsorted);

                homePage.GoToCountries();
            }
        }
        public void LinksOpensInNewTabsTest()
        {
            AdminHomePage homePage = LoginPage.LoginToAdmin();

            homePage.GoToCountries();

            driver.FindElement(By.CssSelector(".button")).Click();

            string maninWindow      = driver.CurrentWindowHandle;
            var    allExternalLinks = driver.FindElements(By.CssSelector(".fa.fa-external-link"));

            foreach (var link in allExternalLinks)
            {
                link.Click();
                CloseNewWindowAndReturnToMain(maninWindow);
            }
        }
        public void ProductsPageLoadsWithoutErrorsTest()
        {
            LoginPage.LoginToAdmin();

            string CssProducts = "a[href*=\"edit_product&category_id\"]:not([title=\"Edit\"])";
            string productsURL = "http://localhost/litecart/admin/?app=catalog&doc=catalog&category_id=1";

            driver.Url = productsURL;

            var products = driver.FindElements(By.CssSelector(CssProducts));

            for (int i = 0; i < products.Count; i++)
            {
                var nodes = driver.FindElements(By.CssSelector(CssProducts));
                nodes[i].Click();
                Assert.IsFalse(BrowserLogsHasErrors(), "the page has errors in logs");
                driver.Url = productsURL;
            }
        }
        public void GeoZonesSortingTest()
        {
            AdminHomePage homePage = LoginPage.LoginToAdmin();

            homePage.GoToGeozones();

            var geoZonesMainCount = driver.FindElements(By.XPath(".//*[@class='dataTable']//tr/td[3]/a")).Count;

            for (int i = 0; i < geoZonesMainCount; i++)
            {
                var zones = driver.FindElements(By.XPath(".//*[@class='dataTable']//tr/td[3]/a"));
                zones[i].Click();
                var listOfZonesForSorting = homePage.GetAllZones();
                listOfZonesForSorting.Sort();

                var listOfZonesUnsorted = homePage.GetAllZones();

                Assert.AreEqual(listOfZonesForSorting, listOfZonesUnsorted);

                homePage.GoToGeozones();
            }
        }
Exemple #5
0
        public void AllMenuElementsTest()
        {
            AdminHomePage homePage       = LoginPage.LoginToAdmin();
            var           mainNodesBlock = driver.FindElements(By.CssSelector(AdminHomePage.CssNodes));

            for (int i = 0; i < mainNodesBlock.Count; i++)
            {
                var nodes = driver.FindElements(By.CssSelector(AdminHomePage.CssNodes));
                nodes[i].Click();

                Assert.IsTrue(this.IsElementPresent(By.CssSelector(AdminHomePage.CssHeader)), "element {0} was not found", AdminHomePage.CssHeader);

                var subNodesCount = driver.FindElements(By.CssSelector(AdminHomePage.CssSubNodes)).Count;
                if (subNodesCount != 0)
                {
                    for (int j = 0; j < subNodesCount; j++)
                    {
                        var subNodes = driver.FindElements(By.CssSelector(AdminHomePage.CssSubNodes));
                        subNodes[j].Click();
                        Assert.IsTrue(this.IsElementPresent(By.CssSelector(AdminHomePage.CssHeader)), "element {0} was not found", AdminHomePage.CssHeader);
                    }
                }
            }
        }
Exemple #6
0
        public void CanAddNewProductTest()
        {
            AdminHomePage homePage = LoginPage.LoginToAdmin();

            homePage.GoToCatalog();

            driver.FindElement(By.CssSelector(".button[href$=\"edit_product\"]")).Click();

            var statusRadioEnabled = driver.FindElement(By.CssSelector("#tab-general label> [value=\"1\"]"));
            var name            = driver.FindElement(By.CssSelector("[name=\"name[en]\"]"));
            var ubberDucksCheck = driver.FindElement(By.CssSelector("[data-name=\"Rubber Ducks\"]"));
            var uniSexCheck     = driver.FindElement(By.CssSelector("[name=\"product_groups[]\"][value=\"1-3\"]"));
            var quantity        = driver.FindElement(By.CssSelector("[name=\"quantity\"]"));
            var uploadImageBnt  = driver.FindElement(By.CssSelector("[name=\"new_images[]\"]"));
            var dateFrom        = driver.FindElement(By.CssSelector("[name=\"date_valid_from\"]"));
            var dateTo          = driver.FindElement(By.CssSelector("[name=\"date_valid_to\"]"));

            string pathToImage = "E:\\SOS\\GitHub\\steam.png";
            string productName = this.GenerateProductName();
            var    saveBtn     = driver.FindElement(By.CssSelector("[name=\"save\"]"));

//            bool isSeleced = false;
//            if (!ubberDucksCheck.Selected)
//            {
//                ubberDucksCheck.Click();
//            }

            statusRadioEnabled.Click();
            name.SendKeys(productName);
            ubberDucksCheck.Click();
            uniSexCheck.Click();
            quantity.SendKeys("10");
            uploadImageBnt.SendKeys(pathToImage);
            dateFrom.SendKeys("07-12-2016");
            dateTo.SendKeys("07-12-2017");

            // open Information tab
            var informationTab = driver.FindElement(By.CssSelector("[href=\"#tab-information\"]"));

            informationTab.Click();

            var manufactirerCombo = driver.FindElement(By.CssSelector("[name=\"manufacturer_id\"]"));
            var supplierCombo     = driver.FindElement(By.CssSelector("[name=\"supplier_id\"]"));
            var descriptionShort  = driver.FindElement(By.CssSelector("[name=\"short_description[en]\"]"));
            var descriptionPane   = driver.FindElement(By.CssSelector(".trumbowyg-editor"));
            var headTitle         = driver.FindElement(By.CssSelector("[name=\"head_title[en]\"]"));

            manufactirerCombo.Click();
            var options = driver.FindElements(By.CssSelector("[name=\"manufacturer_id\"] > option"));

            foreach (var option in options)
            {
                string text = option.GetAttribute("innerText");
                if (text == "ACME Corp.")
                {
                    option.Click();
                    break;
                }
            }

            string paneText =
                "Электрический камин Royal Flame 3D Etna VA -2683 с реалистичным 3D эффект горения.\r\n\r\nЗвук горения дров\r\nТермостат для регулирования заданной температуры в помещении\r\nПульт дистанционного управления\r\n";

            descriptionShort.SendKeys("Short Sescription");
            descriptionPane.SendKeys(paneText);
            headTitle.SendKeys("Head Title");

            // open Prices tab
            var priceTab = driver.FindElement(By.CssSelector("[href=\"#tab-prices\"]"));

            priceTab.Click();

            var purchasePrice = driver.FindElement(By.CssSelector("[name=\"purchase_price\"]"));
            var currencyCombo = driver.FindElement(By.CssSelector("[name=\"purchase_price_currency_code\"]"));
            var priceUsd      = driver.FindElement(By.CssSelector("[name=\"prices[USD]\"]"));

            purchasePrice.SendKeys("1");
            currencyCombo.Click();
            var curencies = driver.FindElements(By.CssSelector("[name=\"purchase_price_currency_code\"]>option"));

            foreach (var item in curencies)
            {
                string text = item.GetAttribute("innerText");
                if (text == "USD")
                {
                    item.Click();
                    break;
                }
            }
            priceUsd.SendKeys("19");

            saveBtn.Click();

            Assert.IsTrue(AdminHomePage.IsProductPresent(productName), "product {0} was not found in catalog", productName);
        }
Exemple #7
0
 public void CanLoginWithValidCredentialsTest()
 {
     LoginPage.LoginToAdmin();
     wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(AdminHomePage.CssLitecartLogo)));
 }