From a6d19da8ad78bd8fe8f0c170af758caa18fda274 Mon Sep 17 00:00:00 2001 From: Roemer Date: Wed, 23 Dec 2015 15:43:20 +0100 Subject: [PATCH] Expose Capture on IUIItem --- src/TestStack.White.UITests/WhiteUITestBase.cs | 2 +- src/TestStack.White/UIItems/IUIItem.cs | 5 +++++ src/TestStack.White/UIItems/UIItem.cs | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/TestStack.White.UITests/WhiteUITestBase.cs b/src/TestStack.White.UITests/WhiteUITestBase.cs index 1ca429ed..85b0f43c 100644 --- a/src/TestStack.White.UITests/WhiteUITestBase.cs +++ b/src/TestStack.White.UITests/WhiteUITestBase.cs @@ -67,7 +67,7 @@ private string TakeScreenshot(string screenshotName) var imagePath = Path.Combine(screenshotDir, imagename); try { - new ScreenCapture().CaptureScreenShot().Save(imagePath, ImageFormat.Png); + Desktop.CaptureScreenshot().Save(imagePath, ImageFormat.Png); Trace.WriteLine(String.Format("Screenshot taken: {0}", imagePath)); } catch (Exception) diff --git a/src/TestStack.White/UIItems/IUIItem.cs b/src/TestStack.White/UIItems/IUIItem.cs index 44da0e67..42058c93 100644 --- a/src/TestStack.White/UIItems/IUIItem.cs +++ b/src/TestStack.White/UIItems/IUIItem.cs @@ -101,5 +101,10 @@ public interface IUIItem : ActionListener void DrawHighlight(); void DrawHighlight(Color color); + + /// + /// Captures an image of the element + /// + Bitmap Capture(); } } \ No newline at end of file diff --git a/src/TestStack.White/UIItems/UIItem.cs b/src/TestStack.White/UIItems/UIItem.cs index e5b09cec..32912e8b 100644 --- a/src/TestStack.White/UIItems/UIItem.cs +++ b/src/TestStack.White/UIItems/UIItem.cs @@ -449,5 +449,10 @@ public virtual void DrawHighlight(Color color) new Drawing.FrameRectangle(color, rectangle).Highlight(); } } + + public virtual Bitmap Capture() + { + return Desktop.CaptureScreenshot(Bounds); + } } } \ No newline at end of file