I've been banging my head against the wall trying to select an option from an ajax enabled select2 select list with the selenium web driver. I've managed to get it working with the IE webdriver but not firefox. Here is my hacky solution for IE
public static void SetSelect2Option(this IWebDriver driver, By locator, string subContainerClass, string searchTerm, TimeSpan? ajaxWaitTimeSpan = null)
var select2Product = driver.FindElement(locator);
var searchBox = driver.FindElement(By.CssSelector(subContainerClass + " .select2-input"));
if (ajaxWaitTimeSpan != null)
var selectedItem = driver.FindElements(By.CssSelector(subContainerClass + " .select2-results li")).First();
In Firefox, this solution works up until the point of the SendKeys call where it just hangs and moves on to the next step without actually firing select2's events to populate the selected item.
I've also tried using the http://code.google.com/p/selenium/wiki/AdvancedUserInteractions API with similar results.
Has anyone run into a similar issue before?