public void Test14()
        {
            AdminPage.Login(driver, "admin", "admin");
            AdminPage.ClickOnHrefOfElements(driver, "li#app- a", "Countries");
            AdminPage.ClickOnHrefOfElements(driver, "td#content a", "Add New Country");

            var    elements   = driver.FindElements(By.CssSelector("i.fa.fa-external-link"));
            string mainWindow = driver.CurrentWindowHandle;

            foreach (var element in elements)
            {
                SwitchToNewWindow(element);
                CloseWindowAndSwitchToMainWindow(mainWindow);
            }
        }
Beispiel #2
0
        public void Test17()
        {
            AdminPage.Login(driver, "admin", "admin");
            AdminPage.ClickOnHrefOfElements(driver, "li#app- a", "Catalog");
            AdminPage.ClickOnHrefOfElements(driver, ".dataTable a", "Rubber Ducks");
            AdminPage.ClickOnHrefOfElements(driver, ".dataTable a", "Subcategory");
            var           objects = driver.FindElements(By.CssSelector(".dataTable a"));
            List <string> hrefs   = new List <string>();


            foreach (var obj in objects)
            {
                var item = obj.GetAttribute("textContent");
                var href = obj.GetAttribute("href");
                if (item != "" && href.Contains("product"))
                {
                    hrefs.Add(href);
                }
            }
            int i = 0;

            foreach (var href in hrefs)
            {
                driver.FindElement(By.CssSelector(string.Format(".dataTable a[href='{0}']", href))).Click();
                var logs = driver.Manage().Logs.GetLog("browser");
                foreach (var log in logs)
                {
                    if (log.Message.Contains("Error"))
                    {
                        Console.WriteLine(log);
                        ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile("screen" + i + ".png", ImageFormat.Png);
                    }
                }
                driver.FindElement(By.CssSelector(".button-set [value=Cancel]")).Click();
                i++;
            }
        }