Has any faced issue when automating auto suggest text box using selenium webdriver



  • 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



  • 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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2