Я пытаюсь выбрать значение с помощью Selenium.
Это цель HTML :
<div class="main_table">
<div class="fields filter_center clearfix" style="margin: 0 auto;">
<div class="form-group clearfix">
<div class="col-sm-8">
<select class="form-control input-sm js-example-basic-single" name="city">
<option style="padding: 3px;" value="213">New York</option>
<option style="padding: 3px;" value="2">Washington</option>
<option style="padding: 3px;" value="47">Los Angeles</option>
Моя первая попытка:
from selenium.webdriver.support.wait import WebDriverWait
region_element = Select(drv.find_element_by_tag_name("select"))
region_element.select_by_value("2")
Это поднимает:
selenium.common.exceptions.ElementNotInteractableException: Message: Element <option> could not be scrolled into view
Моя попытка 2:
region_element = WebDriverWait(drv, 10).until(EC.element_to_be_clickable((By.XPATH, "//select[@name='city']")))
region_element = Select(region_element)
region_element.select_by_value("2")
Опять:
selenium.common.exceptions.ElementNotInteractableException: Message: Element <option> could not be scrolled into view
Попытка 3 (дождитесь, пока определенная опция будеткликабельно):
region_element = WebDriverWait(drv, 10).until(EC.element_to_be_clickable((By.XPATH, "//select[@name='city']")))
WebDriverWait(drv, 10).until(
EC.element_to_be_clickable((By.XPATH, "//select[@name='city']/option[text()='Washington']")))
region_element = Select(region_element)
region_element.select_by_value("2")
Опять же:
selenium.common.exceptions.ElementNotInteractableException: Message: Element <option> could not be scrolled into view
Не могли бы вы помочь мне исправить ситуацию?