Please post your Web Driver questions in official Web Driver forum

Sunday, January 9, 2011

Testing auto suggest using Selenium

Happened to work on Auto Suggest feature of late and was to automate it using Selenium. Auto Suggest feature is similar to suggestion list which is displayed when user types in search term in Google or Yahoo search boxes and a suggestion list is displayed for typed in term.

Started my experiments with "type()" method of selenium but of no avail.
browse through a couple of site and found others have had success using native key press methods. But did not work with me.
Then came across combination of using both "type" and "typeKeys" and voila it worked.

selenium.type(getPageElement("AutoSuggest", "SearchBox").trim(), "");
selenium.typeKeys(getPageElement("AutoSuggest", "SearchBox").trim(), searchTerm);

Though still have some intermittent problems which cause a letter in search term to not be typed in search box in a random fashion, but can live with it for now :-)

Fork me on GitHub