Bug 1411281 - Add equality test for webdriver.Element r=jgraham
authorAndreas Tolfsen <ato@sny.no>
Wed, 25 Oct 2017 09:59:52 +0100
changeset 389032 2e0cca1c1e8723b7b59454eef6aca04dc6374890
parent 389031 4fc2942a3c6935e3514b3c6eb509544f2ba704f0
child 389033 151ca34c9c62bc0fa5be54ee8295a95c60fc6d92
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)
reviewersjgraham
bugs1411281
milestone58.0a1
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 - Add equality test for webdriver.Element r=jgraham 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
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
@@ -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