From 9519ccb8ee872467a894c2de91b1271411d80035 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 10 Jul 2025 08:04:18 -0700 Subject: [PATCH] Scroll grafana pages to force all graphs to load It appears that grafana won't load graph data if you don't scroll past them in the window. Add a js execute script to each of the grafana dashboard screenshot shots that scrolls to the bottom of the page in order to force grafana to render each of the graphs on the page. Change-Id: I12fb2992c3bca2c7ca85f6cedfef8fcdfd64d0a1 --- testinfra/test_grafana.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testinfra/test_grafana.py b/testinfra/test_grafana.py index 6dca78d363..cfc486c9a7 100644 --- a/testinfra/test_grafana.py +++ b/testinfra/test_grafana.py @@ -47,12 +47,18 @@ def test_grafana_screenshots(host): cmd = host.run("curl -s --insecure " "--resolve grafana.opendev.org:443:127.0.0.1 " "https://grafana.opendev.org/api/search") + # Scroll to the bottom of the graph pages to force grafana to render each + # graph on the page. Adapted from: + # https://stackoverflow.com/questions/42982950/how-to-scroll-down-the-page-till-bottomend-page-in-the-selenium-webdriver + scroll_to_bottom = 'window.scrollTo(' \ + '{top: document.body.scrollHeight, left: 0, behavior: "smooth"})' j = json.loads(cmd.stdout) for dashboard in j: url = dashboard["url"] uid = dashboard["uid"] name = dashboard["uri"].split("/")[-1] - shots.append(("https://localhost" + url, None, name + '.png')) + shots.append( + ("https://localhost" + url, scroll_to_bottom, name + '.png')) json_defs.append((uid, name + '.json')) take_screenshots(host, shots) host.run('mkdir /tmp/json_blobs')