Bug 1411281 - Swap webdriver.Element ctor arguments r=jgraham
authorAndreas Tolfsen <ato@sny.no>
Wed, 25 Oct 2017 10:13:18 +0100
changeset 389033 151ca34c9c62bc0fa5be54ee8295a95c60fc6d92
parent 389032 2e0cca1c1e8723b7b59454eef6aca04dc6374890
child 389034 6da19712fa968ee468b33a24d5da605b8f162160
push id32777
push userarchaeopteryx@coole-files.de
push dateMon, 30 Oct 2017 22:44:45 +0000
treeherdermozilla-central@dd0f265a1300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1411281 - Swap webdriver.Element ctor arguments r=jgraham It is more natural for the web element UUID to come first, followed by the associated session state. The patch also adds ctor documentation. MozReview-Commit-ID: 5iV4SZzMeKS
--- a/testing/web-platform/tests/tools/webdriver/webdriver/client.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/client.py
@@ -543,17 +543,17 @@ class Session(object):
         if data is not None:
             return self._element(data)
     def _element(self, data):
         elem_id = data[Element.identifier]
         assert elem_id
         if elem_id in self._element_cache:
             return self._element_cache[elem_id]
-        return Element(self, elem_id)
+        return Element(elem_id, self)
     def cookies(self, name=None):
         if name is None:
             url = "cookie"
             url = "cookie/%s" % name
         return self.send_session_command("GET", url, {})
@@ -614,19 +614,27 @@ class Element(object):
     Representation of a web element.
     A web element is an abstraction used to identify an element when
     it is transported via the protocol, between remote- and local ends.
     identifier = "element-6066-11e4-a52e-4f735466cecf"
-    def __init__(self, session, id):
+    def __init__(self, id, session):
+        """
+        Construct a new web element representation.
+        :param id: Web element UUID which must be unique across
+            all browsing contexts.
+        :param session: Current ``webdriver.Session``.
+        """
+        self.id = id
         self.session = session
-        self.id = id
         assert id not in self.session._element_cache
         self.session._element_cache[self.id] = self
     def __eq__(self, other):
         return isinstance(other, Element) and self.id == other.id \
                 and self.session == other.session
     def send_element_command(self, method, uri, body=None):