Skip to content

test_geojson test does not pass on v0.13.0 tag because of the usage of removed Selenium method #1625

@rominf

Description

@rominf

Describe the bug
Some tests do not pass on v0.13.0 tag because of the usage of removed Selenium method (see: SeleniumHQ/selenium#10712).

To Reproduce
Follow https://github.com/python-visualization/folium/blob/main/.github/CONTRIBUTING.md to run Selenium tests.

===================================================================== test session starts =====================================================================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/rominf/aiven/folium, configfile: setup.cfg
plugins: cov-4.0.0, flake8-1.1.1, forked-1.4.0, xdist-2.5.0, nbval-0.9.6
collected 48 items                                                                                                                                            

tests/selenium/test_geojson_selenium.py F                                                                                                               [  2%]
tests/selenium/test_heat_map_selenium.py .                                                                                                              [  4%]
tests/selenium/test_selenium.py .....................................x........                                                                          [100%]

========================================================================== FAILURES ===========================================================================
________________________________________________________________________ test_geojson _________________________________________________________________________

driver = <conftest.DriverFolium (session="41ea21802f821f8d917ea008756c38df")>

    def test_geojson(driver):
        """Verify that loading data in GeoJson works well for different use cases.
    
        Prevent two regressions:
        - https://github.com/python-visualization/folium/pull/1190
        - https://github.com/python-visualization/folium/pull/1289
    
        """
        data_url = 'https://cdn.jsdelivr.net/gh/python-visualization/folium@main/examples/data/search_bars_rome.json'
    
        m = folium.Map((41.9, 12.5), zoom_start=10, tiles='cartodbpositron')
        marker_cluster = folium.plugins.MarkerCluster(name='cluster').add_to(m)
        folium.GeoJson(data_url, embed=False).add_to(marker_cluster)
        folium.GeoJson(data_url, embed=False, show=False, name='geojson').add_to(m)
        folium.LayerControl(collapsed=False).add_to(m)
    
        html = m.get_root().render()
        with temp_html_filepath(html) as filepath:
            driver.get_file(filepath)
            assert driver.wait_until('.folium-map')
            driver.verify_js_logs()
        # Verify the marker cluster is shown, it's a yellow icon with '18' in it.
        icon = driver.wait_until('.leaflet-marker-icon.marker-cluster > div > span')
        assert icon.text == '18'
        # Verify the second GeoJson layer is not shown, because we used show=False.
        control_label = driver.wait_until(
            '.leaflet-control-layers-overlays > label:nth-of-type(2)'
        )
        assert control_label.text == 'geojson'
>       control_input = control_label.find_element_by_css_selector('input')
E       AttributeError: 'WebElement' object has no attribute 'find_element_by_css_selector'

tests/selenium/test_geojson_selenium.py:35: AttributeError

Expected behavior
All tests pass.

Environment (please complete the following information):

  • Browser: chromedriver
  • Tests
  • Python version: 3.10.6 from conda
  • folium version: 0.13.0
  • branca version: 0.5.0

Additional context
No context.

Possible solutions
Update test code to use actual Selenium methods.

folium is maintained by volunteers. Can you help making a fix for this issue?
No: I believe the fix is quite simple for a knowledgeable person, but it will take some time for me to dig into details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions