Revision: 4438
Author: pekka.klarck
Date: Tue Dec 7 07:06:15 2010
Log: support for taking screenshot on windows when PIL installed
http://code.google.com/p/robotframework/source/detail?r=4438
Modified:
/trunk/src/robot/libraries/Screenshot.py
=======================================
--- /trunk/src/robot/libraries/Screenshot.py Tue Dec 7 06:50:43 2010
+++ /trunk/src/robot/libraries/Screenshot.py Tue Dec 7 07:06:15 2010
@@ -21,6 +21,8 @@
from robot import utils
+take_screenshot = None
+
if sys.platform.startswith('java'):
from java.awt import Toolkit, Robot, Rectangle
from javax.imageio import ImageIO
@@ -32,7 +34,17 @@
image = Robot().createScreenCapture(rectangle)
ImageIO.write(image, "jpg", File(path))
-else:
+elif os.name == 'nt':
+
+ try:
+ from PIL import ImageGrab
+ except ImportError:
+ pass
+ else:
+ def take_screenshot(path):
+ ImageGrab.grab().save(path)
+
+if not take_screenshot:
def take_screenshot(path):
raise RuntimeError('Taking screenshots is not supported on this
platform '