예제 #1
0
        public void Test1()
        {
            IBitmapComparer bitmapComparer = new BitmapComparer();

            var driver = new ChromeDriver(@"Drivers/");

            //var driver = new InternetExplorerDriver(@"Drivers/");

            driver.Navigate().GoToUrl("http://www.thelondonclinic.co.uk");

            WaitForElementToAppear(driver, 2000, By.Id("patient"));

            driver.FindElement(By.Id("patient")).Click();

            WaitForElementToAppear(driver, 2000, By.LinkText("Why choose The London Clinic?"));

            driver.FindElementByLinkText("Why choose The London Clinic?").Click();

            var s = driver.GetScreenshot();

            s.SaveAsFile(@"pic.png", ImageFormat.Png);
            s.SaveAsFile(@"pic2.png", ImageFormat.Png);

            var result = bitmapComparer.AreSame(@"pic.png", @"pic2.png");

            Assert.IsTrue(result);
        }
예제 #2
0
        public void TakesAScreenshotForAWebPageNonMatch()
        {
            var url      = Directory.GetCurrentDirectory() + "/WebPages/DemoPage2.html";
            var filePath = "pic.png";

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            using (var driver = new ChromeDriver(@"Drivers/"))
            {
                var sut = new ScreenshotProvider(driver);
                sut.SaveScreenshot(url, filePath);
            }

            var bitmapComparer = new BitmapComparer();
            var result         = bitmapComparer.AreSame(@"pic.png", @"OldImages/pic.png");

            Assert.IsFalse(result);
        }