Auto -complete text in selenium

SQL Guru
SQL Guru used Ask the Experts™
on
How to fill autocomplete text in selenium-Python Platform.
I need to enter the city information in the textbox.I tried using key.ARROW_DOWN, Keys.RETURN but it didn't workout. This textbox accepts the information only after clicking on the value from the drop-down list else it don't accept it.  I am not sure how to select option from the drop-down list.
Kindly help on this issue.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
import time 
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome('C:\\Users\\Vivekanandhan\\Downloads\\Compressed\\chromedriver_win32\\chromedriver.exe')


driver.get('http://poorvapunya.com/marriage_match_horoscope.php')
girl_name = driver.find_element_by_name("girl_name")
girl_name.send_keys('girl_name')
birth_date_fm= driver.find_element_by_name("birth_date_fm")
birth_date_fm.send_keys('20.9.2017')

select = Select(driver.find_element_by_name('birth_hours_fm'))
select.select_by_value('1')

select = Select(driver.find_element_by_name('birth_minutes_fm'))
select.select_by_value('49')

select = Select(driver.find_element_by_name('birth_ampm_fm'))
select.select_by_value('0')

birth_city_fm = driver.find_element_by_id("birth_city_fm")
birth_city_fm.click()
birth_city_fm.clear()
#birth_city_fm.send_keys('India', Keys.ARROW_DOWN)
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH,'//input[@placeholder="Enter your place of birth and select from list"]'))).send_keys("India")


              
#########################################

boy_name = driver.find_element_by_name("boy_name")
boy_name.send_keys('boy_name')
birth_date_fm= driver.find_element_by_name("birth_date_m")
birth_date_fm.send_keys('20.9.2017')

select = Select(driver.find_element_by_name('birth_hours_m'))
select.select_by_value('1')

select = Select(driver.find_element_by_name('birth_minutes_m'))
select.select_by_value('49')

select = Select(driver.find_element_by_name('birth_ampm_m'))
select.select_by_value('0')

birth_city_m = driver.find_element_by_id("birth_city_m")
birth_city_m.send_keys('India')

driver.find_element_by_xpath(".//*[@type='submit']").click()

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
perhaps:
birth_city_fm.send_keys('Chennai')
time.sleep(3.0)
birth_city_fm.send_keys(Keys.ARROW_DOWN)
birth_city_fm.send_keys(Keys.TAB)

Open in new window

and then later on
birth_city_m.send_keys('Chennai')
time.sleep(3.0)
birth_city_m.send_keys(Keys.ARROW_DOWN)
birth_city_m.send_keys(Keys.TAB)

driver.find_element_by_xpath(".//*[@type='submit']").click()

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial