The class Selenium Select has 3 methods of different option selection:
Now,
My solution is to use xpath to find options that are children of the select. Any xpath method can be used to find the select; in this example I am finding the select by id.
List options = driver.findElements(By.xpath("//select[@id = 'selectId')]/option"));
for (WebElement option : options) {
if (option.getText().contains("DOLLAR")) {
option.click();
break;
}
}
After a little more thought I realize the option can be found entirely with xpath:
driver.findElements(By.xpath("//select[@id = 'selectId')]/option[contains(text(), 'DOLLAR')]")).click();