Skip to content

Commit a7fc4e6

Browse files
committed
export canvas, not full screenshot
1 parent cd2d227 commit a7fc4e6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/selenium/test_heat_map_selenium.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import base64
22
import os
33

44
import folium
@@ -29,8 +29,12 @@ def test_heat_map_with_weights(driver):
2929
driver.get_file(filepath)
3030
assert driver.wait_until('.folium-map')
3131
driver.verify_js_logs()
32-
assert driver.wait_until('canvas.leaflet-heatmap-layer')
33-
screenshot = driver.get_screenshot_as_png()
32+
canvas = driver.wait_until('canvas.leaflet-heatmap-layer')
33+
assert canvas
34+
# get the canvas as a PNG base64 string
35+
canvas_base64 = driver.execute_script(
36+
"return arguments[0].toDataURL('image/png').substring(21);", canvas)
37+
screenshot = base64.b64decode(canvas_base64)
3438
path = os.path.dirname(__file__)
3539
with open(os.path.join(path, 'test_heat_map_selenium_screenshot.png'), 'rb') as f:
3640
screenshot_expected = f.read()
9.69 KB
Loading

0 commit comments

Comments
 (0)