Merge pull request #115 from BlackHC/master

add captureScreenshotAsBase64 and captureScreenshotAsList
diff --git a/lib/src/web_driver.dart b/lib/src/web_driver.dart
index 3e15517..9856950 100644
--- a/lib/src/web_driver.dart
+++ b/lib/src/web_driver.dart
@@ -140,10 +140,25 @@
 
   Mouse get mouse => new Mouse._(this);
 
-  /// Take a screenshot of the current page as PNG.
+  /// Take a screenshot of the current page as PNG and return it as
+  /// base64-encoded string.
+  Future<String> captureScreenshotAsBase64() async =>
+      await getRequest('screenshot');
+
+  /// Take a screenshot of the current page as PNG as list of uint8.
+  Future<List<int>> captureScreenshotAsList() async {
+    var base64Encoded = captureScreenshotAsBase64();
+    return BASE64.decode(await base64Encoded);
+  }
+
+  /// Take a screenshot of the current page as PNG as stream of uint8.
+  ///
+  /// Don't use this method. Prefer [captureScreenshotAsBase64] or
+  /// [captureScreenshotAsList]. Returning the data as Stream<int> can be very
+  /// slow.
+  @Deprecated('Use captureScreenshotAsBase64 or captureScreenshotAsList!')
   Stream<int> captureScreenshot() async* {
-    var encoded = await getRequest('screenshot');
-    yield* new Stream.fromIterable(BASE64.decode(encoded));
+    yield* new Stream.fromIterable(await captureScreenshotAsList());
   }
 
   /// Inject a snippet of JavaScript into the page for execution in the context
diff --git a/test/src/web_driver.dart b/test/src/web_driver.dart
index d00ceff..fd52f0e 100644
--- a/test/src/web_driver.dart
+++ b/test/src/web_driver.dart
@@ -177,6 +177,18 @@
         expect(screenshot, hasLength(isPositive));
         expect(screenshot, everyElement(new isInstanceOf<int>()));
       });
+
+      test('captureScreenshotAsList', () async {
+        var screenshot = await driver.captureScreenshotAsList();
+        expect(screenshot, hasLength(isPositive));
+        expect(screenshot, everyElement(new isInstanceOf<int>()));
+      });
+
+      test('captureScreenshotAsBase64', () async {
+        var screenshot = await driver.captureScreenshotAsBase64();
+        expect(screenshot, hasLength(isPositive));
+        expect(screenshot, new isInstanceOf<String>());
+      });
     });
   });
 }