Path: blob/main/tests/selenium/test_geojson_selenium.py
1601 views
from selenium.webdriver.common.by import By12import folium3import folium.plugins4from folium.utilities import temp_html_filepath567def test_geojson(driver):8"""Verify that loading data in GeoJson works well for different use cases.910Prevent two regressions:11- https://github.com/python-visualization/folium/pull/119012- https://github.com/python-visualization/folium/pull/12891314"""15data_url = "https://cdn.jsdelivr.net/gh/python-visualization/folium@main/examples/data/search_bars_rome.json"1617m = folium.Map((41.9, 12.5), zoom_start=10, tiles="cartodbpositron")18marker_cluster = folium.plugins.MarkerCluster(name="cluster").add_to(m)19folium.GeoJson(data_url, embed=False).add_to(marker_cluster)20folium.GeoJson(data_url, embed=False, show=False, name="geojson").add_to(m)21folium.LayerControl(collapsed=False).add_to(m)2223html = m.get_root().render()24with temp_html_filepath(html) as filepath:25driver.get_file(filepath)26assert driver.wait_until(".folium-map")27driver.verify_js_logs()28# Verify the marker cluster is shown, it's a yellow icon with '18' in it.29icon = driver.wait_until(".leaflet-marker-icon.marker-cluster > div > span")30assert icon.text == "18"31# Verify the second GeoJson layer is not shown, because we used show=False.32control_label = driver.wait_until(33".leaflet-control-layers-overlays > label:nth-of-type(2)"34)35assert control_label.text == "geojson"36control_input = control_label.find_element(By.CSS_SELECTOR, value="input")37assert control_input.get_attribute("checked") is None383940