Пример #1
0
        public void ImageComparison()
        {
            manager.ActiveBrowser.NavigateTo(
                "http://automatetheplanet.com/healthy-diet-menu-generator/");
            HtmlDiv mainArticleDiv =
                manager.ActiveBrowser.Find.ByXPath <HtmlDiv>(
                    "/html/body/div[1]/div[3]/section/article/div");

            System.Drawing.Bitmap divimage = manager.ActiveBrowser.Window.GetBitmap(mainArticleDiv.GetRectangle());

            Bitmap   expectedbmp = (Bitmap)Image.FromFile("mainArticleDivExpected.bmp", true);
            PixelMap expected    = PixelMap.FromBitmap(expectedbmp);
            PixelMap actual      = PixelMap.FromBitmap(divimage);

            Assert.IsTrue(expected.Compare(actual, 5.0));
        }
Пример #2
0
        public void VisualCapturing()
        {
            manager.ActiveBrowser.NavigateTo(
                "http://automatetheplanet.com/healthy-diet-menu-generator/");
            HtmlDiv mainArticleDiv =
                manager.ActiveBrowser.Find.ByXPath <HtmlDiv>(
                    "/html/body/div[1]/div[3]/section/article/div");

            System.Drawing.Bitmap browserImage = manager.ActiveBrowser.Window.GetBitmap();
            System.Drawing.Bitmap divimage     = manager.ActiveBrowser.Window.GetBitmap(mainArticleDiv.GetRectangle());
            string browserImagePath            =
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Concat(Guid.NewGuid().ToString(), @".bmp"));

            browserImage.Save(browserImagePath);
            string mainDivImagePath =
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Concat(Guid.NewGuid().ToString(), @".bmp"));

            divimage.Save(mainDivImagePath);
        }