Пример #1
0
        public void BrokenImage()
        {
            string imgName = DateTime.Now.ToString("dd/MM/yyyy-HH-mm-ss");

            ExtentHtmlReporter reporter = new ExtentHtmlReporter("./ReportsBrokenImage/reports.html");

            var extend = new ExtentReports();

            extend.AttachReporter(reporter);

            var test = extend.CreateTest("stumped");

            IWebDriver driver = new ChromeDriver();

            for (int k = 2; k <= 9; k++)
            {
                string url = FunctionalLib.ReadDataExcel(1, k, 1);

                driver.Navigate().GoToUrl(url);

                driver.Manage().Window.Maximize();
                int sum = (int)(driver.FindElements(By.TagName("img"))).Count;

                Console.WriteLine(sum);
                var Imageslist = new List <ImagesList>();
                var allImages  = driver.FindElements(By.TagName("img"));
                foreach (var img in allImages)
                {
                    var imgSrc = img.GetAttribute("src");
                    Imageslist.Add(new ImagesList {
                        IMAGE = imgSrc
                    });
                    NUnit.Framework.TestContext.Out.WriteLine($"IMAGE:{imgSrc}");
                }
                foreach (var i in Imageslist)
                {
                    var link = i.IMAGE.ToString();

                    if (link == "")
                    {
                        Console.WriteLine("src empty");
                    }
                    else
                    {
                        string brokenlink = link.Substring(8, 2);
                        if (brokenlink.Equals("s3"))
                        {
                            Console.WriteLine(link);
                        }
                    }
                    test.Log(Status.Pass, driver.Title);

                    extend.Flush();
                }
            }
        }
Пример #2
0
        public void BrokenImage()
        {
            IWebDriver driver = new ChromeDriver();

            for (int k = 2; k <= 9; k++)
            {
                string url = FunctionalLib.ReadDataExcel(1, k, 1);

                driver.Navigate().GoToUrl(url);

                driver.Manage().Window.Maximize();
                int sum = (int)(driver.FindElements(By.TagName("img"))).Count;

                Console.WriteLine(sum);
                var Imageslist = new List <ImagesList>();
                var allImages  = driver.FindElements(By.TagName("img"));
                foreach (var img in allImages)
                {
                    var imgSrc = img.GetAttribute("src");
                    Imageslist.Add(new ImagesList {
                        IMAGE = imgSrc
                    });
                    NUnit.Framework.TestContext.Out.WriteLine($"IMAGE:{imgSrc}");
                }
                foreach (var i in Imageslist)
                {
                    var link = i.IMAGE.ToString();

                    if (link == "")
                    {
                        Console.WriteLine("src empty");
                    }
                    else
                    {
                        string brokenlink = link.Substring(8, 2);
                        if (brokenlink.Equals("s3"))
                        {
                            Console.WriteLine(link);
                        }
                    }
                }
            }
        }