[Solved] Python selenium drop down menu click


You should use Select() to select an option from drop down as below :-

from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

 wait = WebDriverWait(driver, 10)


 element = wait.until(EC.visibility_of_element_located((By.ID, "dwfrm_adyenencrypted_expiryMonth")))

 select = Select(element)
 select.select_by_value("04")

Edited :- If unfortunately above does not work you can also try using .execute_script() as below :-

wait = WebDriverWait(driver, 10)


element = wait.until(EC.presence_of_element_located((By.ID, "dwfrm_adyenencrypted_expiryMonth")))

 driver.execute_script("var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].value == arguments[1]){ select.options[i].selected = true; } }", element, "04")

Hope it will work…:)

10

solved Python selenium drop down menu click