Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 39 additions & 15 deletions superset/utils/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,46 @@ def get_screenshot(
sleep(selenium_headstart)

try:
logger.debug("Wait for the presence of %s", element_name)
element = WebDriverWait(driver, self._screenshot_locate_wait).until(
EC.presence_of_element_located((By.CLASS_NAME, element_name))
)
try:
# page didn't load
logger.debug(
"Wait for the presence of %s at url: %s", element_name, url
)
element = WebDriverWait(driver, self._screenshot_locate_wait).until(
EC.presence_of_element_located((By.CLASS_NAME, element_name))
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are most likely going to be network errors, i.e., server is down or url is incorrect, or perhaps permissions - user can't access the page.

except TimeoutException as ex:
logger.exception("Selenium timed out requesting url %s", url)
raise ex

logger.debug("Wait for chart containers to draw")
WebDriverWait(driver, self._screenshot_locate_wait).until(
EC.visibility_of_all_elements_located(
(By.CLASS_NAME, "slice_container")
try:
# chart containers didn't render
logger.debug("Wait for chart containers to draw at url: %s", url)
WebDriverWait(driver, self._screenshot_locate_wait).until(
EC.visibility_of_all_elements_located(
(By.CLASS_NAME, "slice_container")
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These imo are going to be client errors, and will show as errors on the dashboard when the user views it, not just in reports. This is an example where the client db is down. Also dataset role access will show these errors. There's a flag SCREENSHOT_REPLACE_UNEXPECTED_ERRORS to show better errors here in the screenshots.
trino

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one area where I think a warning may make sense. @craig-rueda what do you think here?

)
)
except TimeoutException as ex:
logger.exception(
"Selenium timed out waiting for chart containers to draw at url %s",
url,
)
raise ex

logger.debug("Wait for loading element of charts to be gone")
WebDriverWait(driver, self._screenshot_load_wait).until_not(
EC.presence_of_all_elements_located((By.CLASS_NAME, "loading"))
)
try:
# charts took too long to load
logger.debug(
"Wait for loading element of charts to be gone at url: %s", url
)
WebDriverWait(driver, self._screenshot_load_wait).until_not(

@eschutho eschutho Mar 9, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this error is going to be because the client db took too long to return the data. Some optimization is possible on either the client db or the superset instance to tune timeouts. Warning vs exception here is a little questionable.

EC.presence_of_all_elements_located((By.CLASS_NAME, "loading"))
)
except TimeoutException as ex:
logger.exception(
"Selenium timed out waiting for charts to load at url %s", url
)
raise ex

selenium_animation_wait = current_app.config[
"SCREENSHOT_SELENIUM_ANIMATION_WAIT"
Expand All @@ -215,9 +239,9 @@ def get_screenshot(
)

img = element.screenshot_as_png

except TimeoutException:
logger.exception("Selenium timed out requesting url %s", url)
# raise again for the finally block, but handled above
pass
except StaleElementReferenceException:
logger.exception(
"Selenium got a stale element while requesting url %s",
Expand Down