I have two combo boxes from which I need to get data. Let's call them 'Manufacturers' and 'Models'
When you select a manufacturer from one box the other box populates with the models that the manufacturer produces. This works fine manually but when I select a manufacturer programmatically with Selenium the 'Model' box does not re-populate. Here's the code.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
driver = webdriver.Firefox()
#Base URL
driver.get("https://example.com/")
def scrape():
#get manufacturer list
select1 = driver.find_element_by_name("mnfr")
makes = [x.text for x in select1.find_elements_by_tag_name("option")]
print(makes)
#get models list
for m in makes:
select1a = Select(driver.find_element_by_name("makeCodeListPlaceHolder"))
select1a.select_by_visible_text(m)
select2 = driver.find_element_by_name("models")
models = [x.text for x in select2.find_elements_by_tag_name("option")]
print(models)
scrape()