Bug 1213875 - Add scroll argument to Marionette client; r?whimboo draft
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 20 Dec 2016 14:31:18 +0000
changeset 451496 643256f03c585866c94ed18d7099c4e34eb338a1
parent 451495 49f3d03199d38df9bf8c9640b113604de00681db
child 451497 2ec8b617b93c0e36a0fdb9e7154a2f8773816b2a
push id39205
push userbmo:ato@mozilla.com
push dateTue, 20 Dec 2016 14:32:49 +0000
Bug 1213875 - Add scroll argument to Marionette client; r?whimboo MozReview-Commit-ID: Jg9DW1TDmNS
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -2012,17 +2012,17 @@ class Marionette(object):
         This is the equivalent of calling `document.cookie` and
         parsing the result.
         :returns: A list of cookies for the current domain.
         return self._send_message("getCookies", key="value" if self.protocol == 1 else None)
     def screenshot(self, element=None, highlights=None, format="base64",
-                   full=True):
+                   full=True, scroll=True):
         """Takes a screenshot of a web element or the current frame.
         The screen capture is returned as a lossless PNG image encoded
         as a base 64 string by default. If the `element` argument is defined the
         capture area will be limited to the bounding box of that
         element.  Otherwise, the capture area will be the bounding box
         of the current frame.
@@ -2035,28 +2035,33 @@ class Marionette(object):
         :param format: if "base64" (the default), returns the screenshot
             as a base64-string. If "binary", the data is decoded and
             returned as raw binary. If "hash", the data is hashed using
             the SHA-256 algorithm and the result is returned as a hex digest.
         :param full: If True (the default), the capture area will be the
             complete frame. Else only the viewport is captured. Only applies
             when `element` is None.
+        :param scroll: When `element` is provided, scroll to it before
+            taking the screenshot (default).  Otherwise, avoid scrolling
+            `element` into view.
         if element:
             element = element.id
         lights = None
         if highlights:
             lights = [highlight.id for highlight in highlights]
         body = {"id": element,
                 "highlights": lights,
                 "full": full,
-                "hash": False}
+                "hash": False,
+                "scroll": scroll}
         if format == "hash":
             body["hash"] = True
         data = self._send_message("takeScreenshot", body, key="value")
         if format == "base64" or format == "hash":
             return data
         elif format == "binary":
             return base64.b64decode(data.encode("ascii"))