File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ def _to_png(
368368 Examples
369369 --------
370370 >>> m._to_png()
371- >>> m._to_png(time =10) # Wait 10 seconds between render and snapshot.
371+ >>> m._to_png(delay =10) # Wait 10 seconds between render and snapshot.
372372
373373 """
374374
@@ -392,11 +392,16 @@ def _to_png(
392392 * size ,
393393 )
394394 driver .set_window_size (* window_size )
395+ from selenium .webdriver .support .ui import WebDriverWait
396+
395397 html = self .get_root ().render ()
396398 with temp_html_filepath (html ) as fname :
397399 # We need the tempfile to avoid JS security issues.
398400 driver .get (f"file:///{ fname } " )
399- time .sleep (delay )
401+ WebDriverWait (driver , delay ).until (
402+ lambda _driver : _driver .execute_script ("return document.readyState" )
403+ == "complete"
404+ )
400405 div = driver .find_element ("class name" , "folium-map" )
401406 png = div .screenshot_as_png
402407 driver .quit ()
You can’t perform that action at this time.
0 commit comments