Skip to content

Commit

Permalink
Tuning the Webdriver logging a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
craig-rueda committed Mar 1, 2023
1 parent 134acba commit 247179f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions superset/utils/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ def find_unexpected_errors(driver: WebDriver) -> List[str]:
f"arguments[0].innerHTML = '{error_as_html}'", alert_div
)
except WebDriverException:
logger.warning(
"Failed to update error messages using alert_div", exc_info=True
)
logger.exception("Failed to update error messages using alert_div")
except WebDriverException:
logger.warning("Failed to capture unexpected errors", exc_info=True)
logger.exception("Failed to capture unexpected errors")

return error_messages

Expand Down Expand Up @@ -142,7 +140,7 @@ def create(self) -> WebDriver:
options.add_argument(arg)

kwargs.update(current_app.config["WEBDRIVER_CONFIGURATION"])
logger.info("Init selenium driver")
logger.debug("Init selenium driver")

return driver_class(**kwargs)

Expand Down Expand Up @@ -200,7 +198,7 @@ def get_screenshot(
]
logger.debug("Wait %i seconds for chart animation", selenium_animation_wait)
sleep(selenium_animation_wait)
logger.info(
logger.debug(
"Taking a PNG screenshot of url %s as user %s",
url,
user.username,
Expand All @@ -219,15 +217,16 @@ def get_screenshot(
img = element.screenshot_as_png

except TimeoutException:
logger.warning("Selenium timed out requesting url %s", url, exc_info=True)
logger.exception("Selenium timed out requesting url %s", url)
except StaleElementReferenceException:
logger.error(
logger.exception(
"Selenium got a stale element while requesting url %s",
url,
exc_info=True,
)
except WebDriverException as ex:
logger.error(ex, exc_info=True)
except WebDriverException:
logger.exception(
"Encountered an unexpected error when requeating url %s", url
)
finally:
self.destroy(driver, current_app.config["SCREENSHOT_SELENIUM_RETRIES"])
return img

0 comments on commit 247179f

Please sign in to comment.