Ejemplo n.º 1
0
        public static void VisualCheckpoint(string fileOrFolderPath)
        {
            // Handling of filename / folder
            fileOrFolderPath = fileOrFolderPath.Trim();
            if (!System.IO.File.Exists(fileOrFolderPath) && !System.IO.Directory.Exists(fileOrFolderPath))
            {
                fileOrFolderPath = System.IO.Directory.GetCurrentDirectory() + @"\" + fileOrFolderPath;
            }

            EyesWrapper.StartOrContinueTest(GetTestCaseName());
            EyesWrapper.CheckFolder(fileOrFolderPath);
        }
Ejemplo n.º 2
0
        public static void VisualCheckpoint(Adapter adapter, string stepDescription)
        {
            if (adapter == null)
            {
                throw new ArgumentNullException("adapter");
            }

            EyesWrapper.StartOrContinueTest(GetTestCaseName());
            Report.Info(string.Format("Applitools 'CheckImage' called with screenshot from repository item '{0}'.", adapter));

            try
            {
                ProgressForm.SetOpacity(0);

                Bitmap image;
                if (adapter.Element.HasCapability("webdocument"))
                {
                    var webDocument = adapter.As <WebDocument>();
                    EyesWrapper.SetBrowserName(webDocument.BrowserName);
                    if (EyesWrapper.ViewPortWidth > 0 && EyesWrapper.ViewPortHeight > 0)
                    {
                        webDocument.Browser.Resize(EyesWrapper.ViewPortWidth, EyesWrapper.ViewPortHeight);
                    }

                    webDocument.WaitForDocumentLoaded();
                    image = webDocument.CaptureFullPageScreenshot(screenshotCaptureFlag);
                }
                else
                {
                    var browserName = string.Empty;
                    if (adapter.Element.HasCapability("webelement"))
                    {
                        var parent = adapter.Parent;
                        while (parent.As <WebDocument>() == null)
                        {
                            parent = parent.Parent;
                        }

                        browserName = parent.As <WebDocument>().BrowserName;
                    }

                    EyesWrapper.SetBrowserName(browserName);
                    image = Imaging.CaptureImage(adapter.Element);
                }

                EyesWrapper.CheckImage(image, stepDescription);
            }
            finally
            {
                ProgressForm.SetOpacity(100);
            }
        }