How To Select/click In A Dropdown Content Using Selenium Chromewebdriver / Python
My website form have updated and my script is no more working. I cannot fix it because I'm not able to find how to select in a dropdown content using selenium chrome web driver and
Solution 1:
First try to click to the combobox, then wait until state option(li
) element is visible and click.
In code below, I used css selector to get li
by title
. If you want to find element by text, use:
wait.until(ec.visibility_of_element_located((By.XPATH, f"//li[.='{state}' and @class = 'next-menu-item']"))).click()
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
state = "Alabama"
driver.find_element_by_css_selector('input[placeholder="State/Province/Region"]').click()
wait.until(ec.visibility_of_element_located((
By.CSS_SELECTOR, f"li.next-menu-item[title='{state}']"))).click()
Post a Comment for "How To Select/click In A Dropdown Content Using Selenium Chromewebdriver / Python"