Bug 1411281 - Add equality test for webdriver.Session r=jgraham
authorAndreas Tolfsen <ato@sny.no>
Thu, 26 Oct 2017 17:15:16 +0100
changeset 389031 4fc2942a3c6935e3514b3c6eb509544f2ba704f0
parent 389030 f58e9711dfc55eb245d974b0451e76a6a84dbed6
child 389032 2e0cca1c1e8723b7b59454eef6aca04dc6374890
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.Session r=jgraham When comparing two instances of webdriver.Session we want to first check that there is a current session, then the type of the object to compare with to make sure the "session_id" attribute is present, then finally we compare the session IDs. MozReview-Commit-ID: 6Ch4Uy2MEhB
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
@@ -349,18 +349,23 @@ class UserPrompt(object):
     @text.setter
     @command
     def text(self, value):
         body = {"value": list(value)}
         self.session.send_session_command("POST", "alert/text", body=body)
 
 
 class Session(object):
-    def __init__(self, host, port, url_prefix="/", capabilities=None,
-                 timeout=None, extension=None):
+    def __init__(self,
+                 host,
+                 port,
+                 url_prefix="/",
+                 capabilities=None,
+                 timeout=None,
+                 extension=None):
         self.transport = transport.HTTPWireProtocol(
             host, port, url_prefix, timeout=timeout)
         self.capabilities = capabilities
         self.session_id = None
         self.timeouts = None
         self.window = None
         self.find = None
         self._element_cache = {}
@@ -368,16 +373,20 @@ class Session(object):
         self.extension_cls = extension
 
         self.timeouts = Timeouts(self)
         self.window = Window(self)
         self.find = Find(self)
         self.alert = UserPrompt(self)
         self.actions = Actions(self)
 
+    def __eq__(self, other):
+        return (self.session_id is not None and isinstance(other, Session)
+                and self.session_Id == other.session_id)
+
     def __enter__(self):
         self.start()
         return self
 
     def __exit__(self, *args, **kwargs):
         self.end()
 
     def __del__(self):