I am automating an application which has auto suggest text box. I am facing an issue that sometimes the auto suggest values are not shown up at all. This happens 50% of the time. Worrying part is this never happens when I try manually.

I am using latest version of Selenium WebDriver in .net C# and executing the tests on Chrome.

Here is how the steps are in the Code

  1. Create WebDriver instance
  2. Find the TextBox
  3. TextBox.Click() on the TextBox
  4. TextBox.SendKeys(): I am entering value character wise which reduces the failure rate
  5. WebDriver.wait(wait for dropdown)
  6. TextBox.SendKeys(Keys.DownArrow)
  7. TextBox.SendKeys(Keys.Enter)
  8. TextBox.SendKeys(Keys.Tab)

Any pointers will really be helpful

  • I suppose that the suggest text box does not disappear after some time, right? Jan 17, 2014 at 3:23

6 Answers 6


A little hacky, but might work: You do the SendKeys(), and then wait with a WebDriverWait. I don't really know the C# syntax, but should be similar:

(new WebDriverWait(yourdriver, 10)).until(visibilityOf(theDropdownWebelement));

This would throw a TimeoutException after 10 seconds of not finding the dropdown. Having wrapped all the process in a method, you can do a try/catch where, if you catch the TimeoutException, you just reload the page and try again.

Might not be the most elegant thing ever (at least, I kind of frown upon refreshing pages) but I think it might work.


Such Intermittent faults are the hardest ones to debug.
What I would like to suggest is to look around:

  1. Run tests under Fiddler. This tool may help you to find http requests with errors. Also, it would be helpful to find the request which gets the suggestion list and reissue it several times (there is an option in context menu – reissue request.)
  2. When the failure had happened, do not close the browser window, but check if there are any JavaScript errors in the Chrome Dev tools console.
  3. Try to add Thread.Sleep before failing line. If the code will pass – that means you need to improve your current WebDriverWait expression, for instance, wait for some different element visibility

If nothing will help, and the problem is not reproducible manually, I would suggest changing the test automation code to use mouse clicks instead of SendKeys()


I would have small sleeps (say 100ms) between each keystrokes. This far more human like then the speed in which Selenium can enter text.

Quite often the auto suggest mechanism may be triggered by delays between keystrokes, and entering quickly via selenium may not trigger.


I use the following procedure to perform a similar tests:

TextBox.SendKeys("Test Text");
IWebElement autoCompleteOption = driver.FindElement(By.XPath"//a[contains(text(),'Test Text')]";

The wait step is important to ensure that WebDriver doesn't generate a NoSuchElementException.


I too was facing the same issue. The moment sendkey() method sent the new gmail account to be created in the desired text box, some characters used to appear automatically followed by the one I intended to send. Then i removed the thread.sleep() just before sendKey(). It started working. Please find my below code:

  • I would suggest using wait for element method as discussed in above comment Jun 25, 2019 at 17:13

I suffered similiar problem , I was using the following code to search on instagram.

from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
import time
from selenium.webdriver.common.by import By
driver = webdriver.Firefox(executable_path='/home/blank/Downloads/geckodriver-v0.27.0-linux64/geckodriver')
drop = WebDriverWait(driver,5)

Increasing the limit from 5 to 8 worked for me .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.