Has any faced issue when automating auto suggest text box using selenium webdriver
Mystic last edited by user
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
- Create WebDriver instance
- Find the TextBox
- TextBox.Click() on the TextBox
- TextBox.SendKeys(): I am entering value character wise which reduces the failure rate
- WebDriver.wait(wait for dropdown)
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.