airgun icon indicating copy to clipboard operation
airgun copied to clipboard

Default ensure_page_safe timeout is too short for some pages

Open tpapaioa opened this issue 3 years ago • 0 comments

https://github.com/SatelliteQE/airgun/pull/568 introduced some sleep calls to deal with errors like the following on Cloud Inventory pages:

2021-05-27 15:20:58 - widgetastic_null - DEBUG - [CloudInventoryListView/inventory_list]: click started
2021-05-27 15:20:58 - widgetastic_null - DEBUG - click: <airgun.views.cloud_inventory.InventoryItemsView object at 0x7f0e92a86a90>
2021-05-27 15:20:58 - widgetastic_null - DEBUG - move_to_element: <airgun.views.cloud_inventory.InventoryItemsView object at 0x7f0e92a86a90>
2021-05-27 15:21:28 - widgetastic_null - ERROR - [CloudInventoryListView/inventory_list]: An exception happened during click call (elapsed 29803 ms)
2021-05-27 15:21:28 - widgetastic_null - ERROR - [CloudInventoryListView/inventory_list]: Could not do 'function _check()' at /robottelo/venv/lib64/python3.8/site-packages/widgetastic/browser.py:75 in time
    Traceback (most recent call last):
[...]
      File "/robottelo/venv/lib64/python3.8/site-packages/widgetastic/browser.py", line 1085, in elements
        return self._browser.elements(
      File "/robottelo/venv/lib64/python3.8/site-packages/widgetastic/utils.py", line 695, in wrap
        return method(*args, **kwargs)
      File "/robottelo/venv/lib64/python3.8/site-packages/widgetastic/browser.py", line 302, in elements
        self.plugin.ensure_page_safe()
      File "/robottelo/venv/lib64/python3.8/site-packages/airgun/browser.py", line 588, in ensure_page_safe
        super().ensure_page_safe(timeout)
      File "/robottelo/venv/lib64/python3.8/site-packages/widgetastic/browser.py", line 84, in ensure_page_safe
        wait_for(_check, timeout=timeout, delay=0.2, very_quiet=True)
      File "/robottelo/venv/lib64/python3.8/site-packages/wait_for/__init__.py", line 237, in wait_for
        raise TimedOutError(timeout_msg)
    wait_for.TimedOutError: Could not do 'function _check()' at /robottelo/venv/lib64/python3.8/site-packages/widgetastic/browser.py:75 in time

This is due to the ensure_page_safe() timing out at the beginning of the element lookup method elements(). The cloud inventory report generation and upload tabs can take more than the 30 second default timeout that airgun uses:

airgun/browser.py:

class AirgunBrowserPlugin(DefaultPlugin):

    def ensure_page_safe(self, timeout='30s'):

In my testing, increasing the timeout to '60s' removes the need for any sleep() calls.

tpapaioa avatar May 28 '21 16:05 tpapaioa