Created
May 20, 2014 17:51
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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