Skip to content

Fix sleeping before taking a screenshot in Map._to_png#2220

Merged
hansthen merged 2 commits intopython-visualization:mainfrom
neezr:fix-map-to-png-sleeping
May 1, 2026
Merged

Fix sleeping before taking a screenshot in Map._to_png#2220
hansthen merged 2 commits intopython-visualization:mainfrom
neezr:fix-map-to-png-sleeping

Conversation

@neezr
Copy link
Copy Markdown
Contributor

@neezr neezr commented Apr 30, 2026

In the experimental Map._to_png, currently a selenium WebDriver opens the local HTML file and time.sleep() is used to wait for the folium Map to load before taking the screenshot. In this PR, I replaced time.sleep with WebDriverWait, which actually awaits the Map loading in JavaScript.

The delay variable now specifies the maximum of time to wait, the WebDriverSleep object stops waiting once the page actually loaded.

Also fixed a small typo in the docstring of _to_png.

@hansthen
Copy link
Copy Markdown
Collaborator

Very cool! I am running the tests as we speak, but it looks like it cannot go wrong :-)

@hansthen hansthen merged commit 957a9ad into python-visualization:main May 1, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants