Python/Selenium How to select first option of autocomplete searchbar

Viewed 5468

I am trying to enter a keyword into a searchbar of this site and select the first autocomplete option that comes up. If I were to do this manually I would type in "remote" in the search bar and press the downkey and press enter which I have tried to replicate in my code below, but instead it seems to be skipping the downkey part and not selecting the first autocomplete option and going to the search results page instead of this page which is the first autocomplete option.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
driver.get("https://confluence.eits.uga.edu/dashboard.action")

elem = driver.find_element_by_id("quick-search-query")
elem.send_keys("remote")
elem.send_keys(Keys.ARROW_DOWN)
elem.send_keys(Keys.RETURN)

Anyone have any ideas why the downkey is not being registered or am I not using the right syntax?

2 Answers
Related