This is an automated email from the ASF dual-hosted git repository.
tai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 6b79099 fix: Add waiting time for chart animation when screenshot
(#15610)
6b79099 is described below
commit 6b790990a8f7284b496e5a83e7542155cd543b12
Author: u-aiaa <[email protected]>
AuthorDate: Fri Jul 16 10:25:48 2021 +0900
fix: Add waiting time for chart animation when screenshot (#15610)
---
superset/config.py | 2 ++
superset/utils/webdriver.py | 5 +++++
tests/integration_tests/thumbnails_tests.py | 15 +++++++++++++++
3 files changed, 22 insertions(+)
diff --git a/superset/config.py b/superset/config.py
index 92d9c3b..0e3ed1a 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -499,6 +499,8 @@ SCREENSHOT_LOAD_WAIT = 60
SCREENSHOT_SELENIUM_RETRIES = 5
# Give selenium an headstart, in seconds
SCREENSHOT_SELENIUM_HEADSTART = 3
+# Wait for the chart animation, in seconds
+SCREENSHOT_SELENIUM_ANIMATION_WAIT = 5
# ---------------------------------------------------
# Image and file configuration
diff --git a/superset/utils/webdriver.py b/superset/utils/webdriver.py
index 40427ac..eee8874 100644
--- a/superset/utils/webdriver.py
+++ b/superset/utils/webdriver.py
@@ -120,6 +120,11 @@ class WebDriverProxy:
(By.CLASS_NAME, "slice_container")
)
)
+ selenium_animation_wait = current_app.config[
+ "SCREENSHOT_SELENIUM_ANIMATION_WAIT"
+ ]
+ logger.debug("Wait %i seconds for chart animation",
selenium_animation_wait)
+ sleep(selenium_animation_wait)
logger.info("Taking a PNG screenshot or url %s", url)
img = element.screenshot_as_png
except TimeoutException:
diff --git a/tests/integration_tests/thumbnails_tests.py
b/tests/integration_tests/thumbnails_tests.py
index 62366e4..5eabc4d 100644
--- a/tests/integration_tests/thumbnails_tests.py
+++ b/tests/integration_tests/thumbnails_tests.py
@@ -102,6 +102,21 @@ class TestWebDriverProxy(SupersetTestCase):
webdriver.get_screenshot(url, "chart-container", user=user)
assert mock_webdriver_wait.call_args_list[1] == call(ANY, 15)
+ @patch("superset.utils.webdriver.WebDriverWait")
+ @patch("superset.utils.webdriver.firefox")
+ @patch("superset.utils.webdriver.sleep")
+ def test_screenshot_selenium_animation_wait(
+ self, mock_sleep, mock_webdriver, mock_webdriver_wait
+ ):
+ webdriver = WebDriverProxy("firefox")
+ user = security_manager.get_user_by_username(
+ app.config["THUMBNAIL_SELENIUM_USER"]
+ )
+ url = get_url_path("Superset.slice", slice_id=1, standalone="true")
+ app.config["SCREENSHOT_SELENIUM_ANIMATION_WAIT"] = 4
+ webdriver.get_screenshot(url, "chart-container", user=user)
+ assert mock_sleep.call_args_list[1] == call(4)
+
class TestThumbnails(SupersetTestCase):