[FIXED] Wie kann ich eine Option in einer Liste über Selen auswählen?

Ausgabe

Mein Code ist:

WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, "//option[@value='/icpplustieb/citar?p=8&locale=es']"))).click()

Die URL lautet: https://icp.administracionelectronica.gob.es/icpplus/index.html

Ich möchte Barcelona als Region auswählen.

Lösung

Verwenden Sie die select()Selenklasse

select =Select(WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, "//select[@id='form']"))))
select.select_by_visible_text("Barcelona")

Sie müssen die folgende Bibliothek importieren.

from selenium.webdriver.support.ui import Select


Beantwortet von –
KunduK


Antwort geprüft von –
Mildred Charles (FixError Admin)

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

[FIXED] Selenium – erhalten Sie eine Zahl als Wert

Ausgabe Das ist mein Code: chrome_driver_path = 'C:\Development\chromedriver.exe' driver = webdriver.Chrome(chrome_driver_path) driver.get('https://orteil.dashnet.org/cookieclicker/') button = driver.find_element_by_css_selector('#bigCookie') driver.implicitly_wait(5) my_path =…