vendredi 25 décembre 2020

Pb to select a text from a dropdown list

I started learning Python/Selenium.

After several attempts, I can't find a way to extract the text from a dropdown list, and I would like to put a for loop after the first extraction.

this is the image: enter image description here

the link : enter link description here

driver = webdriver.Chrome("/Users/Hassan/Downloads/chromedriver")
driver.get("http://rgphentableaux.hcp.ma/Default1/")

# Click on "Langues locales utilisées"
langues_check = driver.find_element_by_xpath("//input[@value='5']")
driver.execute_script("arguments[0].click();", langues_check)
# Cliquer sur "Régions"
region_check = driver.find_element_by_xpath("//input[@value='Region']")
driver.execute_script("arguments[0].click();", region_check)
# Cliquer sur "Choisir une région"
choisir_region = driver.find_element_by_xpath("//input[@value='Choisir une entitée']")
driver.execute_script("arguments[0].click();", choisir_region)

#select region
#element = WebDriverWait(driver,5).until(EC.element_to_be_clickable((By.XPATH, "(//li[@class='active-result highlighted'])")))
element = driver.find_element_by_xpath(".//*[@data-option-array-index='0']")
driver.execute_script("arguments[0].click();", element)

# Click on "Afficher"
afficher_click = driver.find_element_by_xpath("//input[@value='Afficher']")
driver.execute_script("arguments[0].click();", afficher_click)



Aucun commentaire:

Enregistrer un commentaire