Bug 1411281 - Add equality test for webdriver.Element
When comparing two instances of webdriver.Element we want to first
check the type, to make sure the "id" attribute is present, then
compare the web element reference UUIDs. These are supposed to be
unique across all browsing contexts.
MozReview-Commit-ID: 68PUBQxPdQ5
--- a/testing/web-platform/tests/tools/webdriver/webdriver/client.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/client.py
@@ -620,16 +620,20 @@ class Element(object):
identifier = "element-6066-11e4-a52e-4f735466cecf"
def __init__(self, session, 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):
url = "element/%s/%s" % (self.id, uri)
return self.session.send_session_command(method, url, body)
def json(self):
return {Element.identifier: self.id}
@command