I'm trying to print the options and select "Manhattan" from the "city" dropdown search box on this website: https://upxland.me/properties/ . But every time I run it, the program end without printing anything. In addition, could anyone show me how to type part of a city's name (like "Manha") and then select from the dropdown list?
My code is shown below. Could anyone help?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import Select
import time
PATH = "/usr/local/bin/chromedriver"
driver = webdriver.Chrome(PATH)
driver.get("https://upxland.me/properties/")
try:
city = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, 'input-74')))
# city.send_keys("o")
# city.send_keys(Keys.RETURN)
city_selection = Select(city)
# print the number of option
print(len(city_selection.options))
# print all options
for option in city_selection.options:
print(option.text)
# select by index
city_selection.select_by_index(3)
time.sleep(3)
# select by value
# city_selection.select_by_value()
except:
driver.quit()