If you look at the page source, you’ll understand that almost all of theSELECT
, DIV
elements are faked
and created from JavaScript, that is why webdriver cannot SEE them.
There’s a workaround though, by using ActionChains
to open your developer console, and inject an artificial CLICK on the desired element, which in fact, is the Label triggering the NBA data loading… here’s a working example:
from selenium import webdriver
from selenium.webdriver.common import action_chains, keys
import time
driver = webdriver.Firefox()
driver.get('Your URL here...')
assert 'NBA' in driver.page_source
action = action_chains.ActionChains(driver)
# open up the developer console, mine on MAC, yours may be diff key combo
action.send_keys(keys.Keys.COMMAND+keys.Keys.ALT+'i')
action.perform()
time.sleep(3)
# this below ENTER is to rid of the above "i"
action.send_keys(keys.Keys.ENTER)
# inject the JavaScript...
action.send_keys("document.querySelectorAll('label.boxed')[1].click()"+keys.Keys.ENTER)
action.perform()
Alternatively to replace all the ActionChains
commands, you can simply run execute_script
like this:
driver.execute_script("document.querySelectorAll('label.boxed')[1].click()")
There you go, at least on my local file anyway… Hope this helps!