Skip to content

Instantly share code, notes, and snippets.

@upgundecha
Created May 20, 2014 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save upgundecha/8abb68ab23be40b88b51 to your computer and use it in GitHub Desktop.
Save upgundecha/8abb68ab23be40b88b51 to your computer and use it in GitHub Desktop.
A simple Selenium wrapper for handling Select element rendered by Chosen jQuery Plug-In. Vanilla version works well with Standard Select
public class ChosenSelect
{
IWebElement containerElem;
public ChosenSelect(IWebElement element)
{
containerElem = element;
}
public void SelectByText(String text)
{
containerElem.FindElement(By.TagName("a")).Click(); //this opens the dropdown
var options = containerElem.FindElements(By.TagName("li"));
foreach(IWebElement option in options)
{
if (option.Text.Equals(text))
{
option.Click();
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment