I am working with this website: https://www.offerte.smartpaws.de/
I came with this dropdown for breeds (Rasse) where unlike other droptdowns I do not find the option description list that allows me to loop through each element.
The values change based on the previous element (yes, no right above)
I am looking to loop through each option in this droptown but can't figure out how.
so far I have this code to try to loop through it:
#y is based on previous element being yes or no, since dropdown changes based on it
if y == 'yes':
#size is a list of a few examples inside the dropdown, Ideally I don't want to have a list hardcoded but to go through all the options available
for size in sizes:
#below I click on the dropdown to display the elements
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="select2-id_form-0-breed-container"]'))).click()
#below I try to click on the option containing the text in the list
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
'//select[@id="select2-id_form-0-breed-container"]//option[text()=' +
size +']'))).click()
#below is the same step but for option "no" in the previous element, and same logic as the previous step
else:
for breed in breeds_dog:
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, '//*[@id="select2-id_form-0-breed-container"]'))).click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
'//select[@id="select2-id_form-0-breed-container"]//option[text()=' +
breed + ']'))).click()
The goal is to be able to loop through all the breed option (for dogs for now) ideally without having to store the list in the code, but to loop through the options. As we can see in the website this element does not store a list of options.
Thanks