Skip to content

Commit

Permalink
chore: log different selenium timeout errors differently (#23290)
Browse files Browse the repository at this point in the history
  • Loading branch information
eschutho committed Mar 9, 2023
1 parent 57db8f9 commit 989fe27
Showing 1 changed file with 39 additions and 15 deletions.
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))
)
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")
)
)
)
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(
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

0 comments on commit 989fe27

Please sign in to comment.