bug 1499057: webdriver: remove known web element cache; r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Thu, 18 Oct 2018 15:34:06 +0000
changeset 490332 55724db90e3e23b09e946681067567c489023249
parent 490331 b5b389d5788ed89f7e666c4de6e80e6a3cb99a19
child 490333 17432131026dfd5e16a8a2935fa4421c56be585e
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerswhimboo
bugs1499057
milestone64.0a1
bug 1499057: webdriver: remove known web element cache; r=whimboo The known web element cache in the WebDriver test client, or webdriver.Session._element_cache, is used only to avoid constructing new webdriver.Element instances of the same web element and serves no practical purpose beyond that Since this client is intended for testing purposes, we would like to be able to construct duplicate webdriver.Element instances, so that e.g. fake elements can be constructed and send to the remote end. Depends on D9127 Differential Revision: https://phabricator.services.mozilla.com/D8855
testing/web-platform/tests/tools/webdriver/webdriver/client.py
--- a/testing/web-platform/tests/tools/webdriver/webdriver/client.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/client.py
@@ -371,17 +371,16 @@ class Session(object):
         self.transport = transport.HTTPWireProtocol(
             host, port, url_prefix, timeout=timeout)
         self.requested_capabilities = capabilities
         self.capabilities = None
         self.session_id = None
         self.timeouts = None
         self.window = None
         self.find = None
-        self._element_cache = {}
         self.extension = None
         self.extension_cls = extension
 
         self.timeouts = Timeouts(self)
         self.window = Window(self)
         self.find = Find(self)
         self.alert = UserPrompt(self)
         self.actions = Actions(self)
@@ -664,32 +663,26 @@ class Element(object):
 
         :param id: Web element UUID which must be unique across
             all browsing contexts.
         :param session: Current ``webdriver.Session``.
         """
         self.id = id
         self.session = session
 
-        if id in self.session._element_cache:
-            raise ValueError("Element already in cache: %s" % id)
-        self.session._element_cache[self.id] = self
-
     def __repr__(self):
         return "<%s %s>" % (self.__class__.__name__, self.id)
 
     def __eq__(self, other):
         return (isinstance(other, Element) and self.id == other.id and
                 self.session == other.session)
 
     @classmethod
     def from_json(cls, json, session):
         uuid = json[Element.identifier]
-        if uuid in session._element_cache:
-            return session._element_cache[uuid]
         return cls(uuid, session)
 
     def send_element_command(self, method, uri, body=None):
         url = "element/%s/%s" % (self.id, uri)
         return self.session.send_session_command(method, url, body)
 
     @command
     def find_element(self, strategy, selector):