Revision: 4439
Author: pekka.klarck
Date: Tue Dec 7 07:15:20 2010
Log: take screenshot when gtk module is available (impl on windows and code
not yet tested)
http://code.google.com/p/robotframework/source/detail?r=4439
Modified:
/trunk/src/robot/libraries/Screenshot.py
=======================================
--- /trunk/src/robot/libraries/Screenshot.py Tue Dec 7 07:06:15 2010
+++ /trunk/src/robot/libraries/Screenshot.py Tue Dec 7 07:15:20 2010
@@ -44,6 +44,24 @@
def take_screenshot(path):
ImageGrab.grab().save(path)
+if not take_screenshot:
+ try:
+ from gtk import gdk
+ except ImportError:
+ pass
+ else:
+ # Code below originally from
http://ubuntuforums.org/showpost.php?p=2681009&postcount=5
+ # TODO: Cleanup
+ def take_screenshot(path):
+ window = gdk.get_default_root_window()
+ size = window.get_size()
+ pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, size[0], size[1])
+ pb = pb.get_from_drawable(window, window.get_colormap(),
+ 0, 0, 0, 0, size[0], size[1])
+ if not pb:
+ raise RuntimeError('Taking screenshot failed')
+ pb.save()
+
if not take_screenshot:
def take_screenshot(path):