From 58f9be9b85cfd34f861d232cf834c96747133a39 Mon Sep 17 00:00:00 2001 From: Mehmet Salih Yavuz Date: Wed, 13 Nov 2024 15:16:33 +0300 Subject: [PATCH] fix(empty dashboards): Allow downloading a screenshot of an empty dashboard (#30767) Co-authored-by: Geido <60598000+geido@users.noreply.github.com> --- superset/utils/webdriver.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/superset/utils/webdriver.py b/superset/utils/webdriver.py index 3e4705da6ee7e..6a334e1c5fcb8 100644 --- a/superset/utils/webdriver.py +++ b/superset/utils/webdriver.py @@ -379,11 +379,19 @@ def get_screenshot(self, url: str, element_name: str, user: User) -> bytes | Non ) ) except TimeoutException: - logger.exception( - "Selenium timed out waiting for chart containers to draw at url %s", - url, - ) - raise + # Fallback to allow a screenshot of an empty dashboard + try: + WebDriverWait(driver, 0).until( + EC.visibility_of_all_elements_located( + (By.CLASS_NAME, "grid-container") + ) + ) + except: + logger.exception( + "Selenium timed out waiting for dashboard to draw at url %s", + url, + ) + raise try: # charts took too long to load