Unable to click invisible select python
<p>I am trying to retrieve all possible lists from <a href="https://www.osram-americas.com/en-us/applications/automotive-lighting-systems/Pages/lrgmain.aspx" rel="nofollow">this website</a></p>

<p>Model will only open when year is selected. Similarly Make will only open when Model is selected. I want to store all combination of Year, Model and Make for learning purpose.</p>

<p>However I am not able to click year field only. It seems it is hidden and without this I can't go ahead with rest of code.</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_id('sbToggle_27562807')
el.click()
</code></pre>

<p>It gives error :-</p>

<blockquote>
  <p>Message: no such element: Unable to locate element: {"method":"id","selector":"sbToggle_27562807"}</p>
</blockquote>

<blockquote>
  <p>Message: no such element: Unable to locate element: {"method":"id","selector":"sbToggle_27562807"}</p>
</blockquote>

<p><code>year</code> element is not hidden, actually your locator to locate element using <code>find_element_by_id('sbToggle_27562807')</code> is not correct. In this element <code>id</code> attribute value is dynamically changing that's why you're unable to locate this element.</p>

<p>Instead of <code>id</code> locator you should try using some different locator. I would suggest, for better way try using <code>find_element_by_css_selector()</code> as below :-</p>

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

python selenium web-scraping