Backed out changeset 5df04b130a16 (
bug 1499057) for Wd failures in /webdriver/tests/element_send_keys/interactability.py CLOSED TREE
--- a/testing/web-platform/tests/tools/webdriver/webdriver/client.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/client.py
@@ -371,16 +371,17 @@ 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)
@@ -663,26 +664,32 @@ 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):