From f0055574dfc285608e0d67d246ddc206d31152dd Mon Sep 17 00:00:00 2001 From: "intermittent.energy" Date: Sun, 15 Oct 2023 20:09:19 +0200 Subject: [PATCH] Wait for panels state=Done --- grafanimate/marionette.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grafanimate/marionette.py b/grafanimate/marionette.py index 6a418f4..34308f1 100644 --- a/grafanimate/marionette.py +++ b/grafanimate/marionette.py @@ -4,6 +4,7 @@ import atexit import json import logging +import time from collections import OrderedDict import where @@ -170,6 +171,16 @@ def render_image(self, element=None): """ Return screenshot from element. """ + while True: + result = self.marionette.execute_script(''' + panels = Object.values(window.wrappedJSObject.grafanaRuntime.getPanelData()) + return panels.length && panels.every(function(o) {return o?.state=='Done'}) + ''') + if result: + break + logger.info("waiting for panels to load") + time.sleep(0.1) + image = self.marionette.screenshot(element=element, format="binary") return image