Bug 1308453 - Backwards compat for old Marionette:timeouts API; r?whimboo
Since the Marionette Python client is being used for upgrade tests
it needs to remain backwards compatible with earlier Gecko versions.
Bug 1302707 changed the Marionette:timeouts API, and this patch addresses
the fallout caused by that.
When sending the new command format and it returns with an error, we try
again with the old format if the error message contained "Not a Number".
This is not ideal, but a natural consequence of poor error typing in
the past.
We can remove this workaround when Firefox 51 becomes the stable train.
MozReview-Commit-ID: JxQAuKnojPB
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1229,45 +1229,66 @@ class Marionette(object):
If a script does not return in the specified amount of time,
a ScriptTimeoutException is raised.
:param timeout: The maximum number of milliseconds an asynchronous
script can run without causing an ScriptTimeoutException to
be raised
"""
- self._send_message("timeouts", {"script": timeout})
+ try:
+ self._send_message("timeouts", {"script": timeout})
+ except errors.MarionetteException as e:
+ # remove when 52.0a is stable
+ if "Not a Number" in e.message:
+ self._send_message("timeouts", {"type": "script", "ms": timeout})
+ else:
+ raise e
def set_search_timeout(self, timeout):
"""Sets a timeout for the find methods.
When searching for an element using
either :class:`Marionette.find_element` or
:class:`Marionette.find_elements`, the method will continue
trying to locate the element for up to timeout ms. This can be
useful if, for example, the element you're looking for might
not exist immediately, because it belongs to a page which is
currently being loaded.
:param timeout: Timeout in milliseconds.
"""
- self._send_message("timeouts", {"implicit": timeout})
+ try:
+ self._send_message("timeouts", {"implicit": timeout})
+ except errors.MarionetteException as e:
+ # remove when 52.0a is stable
+ if "Not a Number" in e.message:
+ self._send_message("timeouts", {"type": "implicit", "ms": timeout})
+ else:
+ raise e
def set_page_load_timeout(self, timeout):
"""Sets a timeout for loading pages.
A page load timeout specifies the amount of time the Marionette
instance should wait for a page load operation to complete. A
``TimeoutException`` is returned if this limit is exceeded.
:param timeout: Timeout in milliseconds.
"""
- self._send_message("timeouts", {"page load": timeout})
+ try:
+ self._send_message("timeouts", {"page load": timeout})
+ except errors.MarionetteException as e:
+ # remove when 52.0a is stable
+ if "Not a Number" in e.message:
+ self._send_message("timeouts", {"type": "page load", "ms": timeout})
+ else:
+ raise e
@property
def current_window_handle(self):
"""Get the current window's handle.
Returns an opaque server-assigned identifier to this window
that uniquely identifies it within this Marionette instance.
This can be used to switch to this window at a later point.