I want to dynamically retrieve the name of states, which differ across season, year and scheme, and assign that to a vector. Such that I could call that vector in a for loop to scrape district level data, which is visible only if I click on state names.
When I inspect the state name this is what I found:
<a title="ANDAMAN AND NICOBAR ISLANDS" style="cursor: pointer; text-decoration: underline; font-weight: bold; white-space: nowrap;">ANDAMAN AND NICOBAR ISLANDS</a>
<a title="ANDHRA PRADESH" style="cursor: pointer; text-decoration: underline; font-weight: bold; white-space: nowrap;">ANDHRA PRADESH</a>
This is the code I used for dynamically retrieving state name for each year, season and scheme sequentially:
# Dynamically retrieve the list of states after selecting year, season, and scheme
state_elements = driver.find_elements(By.XPATH, '//a[contains(@title, " ")]')
states = [elem.get_attribute('title') for elem in state_elements]
Above code, although worked but is pulling only some states. I want to know why is it so.