Not able to select value - error "Select only works on <select> elements, not on <a>"
<p>I am trying to retrieve all possible year, model and make from [<a href="https://www.osram-americas.com/en-us/applications/automotive-lighting-systems/Pages/lrgmain.aspx]" rel="nofollow">https://www.osram-americas.com/en-us/applications/automotive-lighting-systems/Pages/lrgmain.aspx]</a></p>

<pre><code>from selenium import webdriver
import time
from selenium.webdriver.support.ui import Select
from bs4 import BeautifulSoup

driver = webdriver.Chrome()
driver.get("https://www.osram-americas.com/en-us/applications/automotive-lighting-systems/Pages/lrgmain.aspx")
# Switch to new window opened
driver.switch_to.window(driver.window_handles[-1])
# Close the new window
driver.close()
# Switch back to original browser (first window)
driver.switch_to.window(driver.window_handles[0])

el = driver.find_element_by_css_selector("div#fldYear a.sbToggle")
el.click()
select = Select(el)
select.select_by_visible_text("2016")
</code></pre>

<p>However if I try to select year 2016. It is giving error :
Select only works on <code>&lt;select&gt;</code> elements, not on <code>&lt;a&gt;</code></p>

<p>You don't actually need <code>selenium</code> and automate any visual interactions to get the year+make+model data from the page and can approach the problem with <a href="http://docs.python-requests.org/en/master/" rel="nofollow"><code>requests</code></a> only making appropriate GET requests:</p>

<pre><code># -*- coding: utf-8 -*-
from collections import defaultdict
from pprint import pprint

import requests

year = 2016
d = defaultdict(lambda: defaultdict(list))
with requests.Session() as session:
    session.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'}
    session.get("https://www.osram-americas.com/en-us/applications/automotive-lighting-systems/Pages/lrgmain.aspx")

    while True:
        response = session.get("https://www.osram-americas.com/_Layouts/Sylvania.Web.LRGHandler/LRGHandler.ashx",
                               params={"rt": "fetchmake", "year": str(year)})

        data = response.json()
        if not data:  # break if no makes in a year
            break

        for make in data:
            response = session.get("https://www.osram-americas.com/_Layouts/Sylvania.Web.LRGHandler/LRGHandler.ashx",
                                   params={"rt": "fetchmodel", "year": str(year), "make": make["Id"]})

            for model in response.json():
                d[year][make["Value"]].append(model["Value"])

        year -= 1

pprint(dict(d))
</code></pre>

python selenium web-scraping