diff --git a/superset/utils/webdriver.py b/superset/utils/webdriver.py index 991790339a053..b1ba784281082 100644 --- a/superset/utils/webdriver.py +++ b/superset/utils/webdriver.py @@ -177,16 +177,19 @@ def get_screenshot( element = WebDriverWait(driver, self._screenshot_locate_wait).until( EC.presence_of_element_located((By.CLASS_NAME, element_name)) ) - logger.debug("Wait for .loading to be done") - WebDriverWait(driver, self._screenshot_load_wait).until_not( - EC.presence_of_all_elements_located((By.CLASS_NAME, "loading")) - ) - logger.debug("Wait for chart to have content") + + 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") ) ) + + 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")) + ) + selenium_animation_wait = current_app.config[ "SCREENSHOT_SELENIUM_ANIMATION_WAIT" ] diff --git a/tests/integration_tests/thumbnails_tests.py b/tests/integration_tests/thumbnails_tests.py index 0ee420fda8e76..efa0d73cb49f0 100644 --- a/tests/integration_tests/thumbnails_tests.py +++ b/tests/integration_tests/thumbnails_tests.py @@ -180,7 +180,7 @@ def test_screenshot_selenium_load_wait(self, mock_webdriver, mock_webdriver_wait ) url = get_url_path("Superset.slice", slice_id=1, standalone="true") webdriver.get_screenshot(url, "chart-container", user=user) - assert mock_webdriver_wait.call_args_list[1] == call(ANY, 15) + assert mock_webdriver_wait.call_args_list[2] == call(ANY, 15) @patch("superset.utils.webdriver.WebDriverWait") @patch("superset.utils.webdriver.firefox")