I'm trying to create a Selenium Python script that finds a location on a map website (openstreetmap.org to be specific) according to input from the user (i.e. "Moscow"), then chooses a specific graphic layer for the map from the horizontal dropdown, also based on user input.
My script enters the website, opens the dropdown menu and finds the element containing the layer options, which is an unordered list.
However, I find that only 2 of the 5 layer options are being extracted. More so, the first extracted list item is the third option on the website and the second is the first option.
Here is my code. Entering openstreetmap.org:
base_url = 'https://www.openstreetmap.org/search?query=' + place_name
browser = webdriver.Firefox()
browser.get(base_url)
browser.implicitly_wait(3)
Opening the horizontal dropdown:
link_to_buttons = browser.find_elements_by_css_selector('a.control-button')
link_to_buttons[3].click()
Extracting the unordered list:
link_to_options = browser.find_elements_by_css_selector('ul.list-unstyled')