Search code examples
pythonseleniumautocompletegeckodriver

Autocomplete Input with Python Selenium Not Working


I'm trying to fill an autocomplete input on this website google.com/flights but it seems something is not working as expected. When I check the output the input is clicked but the word "NYC" is never filled on the input. Test was done using Firefox with Geckodriver, last stable versions.

Here is the code:

inputElement = self.driver.find_element_by_css_selector('div.e5F5td.BGeFcf div.dvO2xc.k0gFV input')
inputElement.send_keys('NYC')

Here is a screenshot of what the browser sees after executing the code. https://snipboard.io/i1YVNC.jpg


Solution

  • After inserting the NYC to inputElement suggested inputs are appearing.
    You can select one of them.
    For example to select LGA airport you can click this element:

    self.driver.find_element_by_xpath("//li[@data-code='LGA']").click()
    

    upd
    After clarifying the problem finally solved with sending the text with Actions instead of Selenium driver.