Commit 6225766 1 parent dd2a8d3 commit 6225766 Copy full SHA for 6225766
File tree 1 file changed +7
-0
lines changed
src/TestStack.White/UIItems
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public class UIItem : IUIItem
35
35
protected readonly PrimaryUIItemFactory factory ;
36
36
internal readonly Keyboard keyboard = Keyboard . Instance ;
37
37
protected IScrollBars scrollBars ;
38
+ private static readonly ScreenCapture ScreenCapture = new ScreenCapture ( ) ;
38
39
private AutomationEventHandler handler ;
39
40
protected readonly ILogger Logger = CoreAppXmlConfiguration . Instance . LoggerFactory . Create ( typeof ( UIItem ) ) ;
40
41
@@ -234,6 +235,12 @@ public virtual Bitmap VisibleImage
234
235
{
235
236
get
236
237
{
238
+ if ( automationElement . Current . NativeWindowHandle == 0 )
239
+ {
240
+ // In wpf controls does not have window handles, falling back to screencapture.
241
+ return ScreenCapture . CaptureArea ( Bounds ) ;
242
+ }
243
+
237
244
var displayedItem = new DisplayedItem ( new IntPtr ( automationElement . Current . NativeWindowHandle ) ) ;
238
245
using ( System . Drawing . Image image = displayedItem . GetVisibleImage ( ) )
239
246
return new Bitmap ( image ) ;
You can’t perform that action at this time.
0 commit comments