Вот как я это делаю.
Шаг сценария Specflow
And the 'TimeZoneId' dropdown should contain the values
| Value | Text |
| | --Select-- |
| Dateline Standard Time | (UTC-12:00) International Date Line West |
| UTC-11 | (UTC-11:00) Coordinated Universal Time-11 |
| Hawaiian Standard Time | (UTC-10:00) Hawaii |
И реализованное определение шага, где p0 - имя элемента select
[Then(@"the '(.*)' dropdown should contain the values")]
public void ThenTheDropdownShouldContainTheValues(string p0, Table table)
{
var dropdown = new SelectElement(Selenium.FindElement(By.Name(p0)));
var dropDownTextValues = dropdown.Options.Select(webElement => webElement.Text).ToList();
var textValues = table.Rows.Select(x => x[1]).ToList();
CollectionAssert.AreEquivalent(dropDownTextValues, textValues);
var dropDownValues = dropdown.Options.Select(webElement => webElement.GetAttribute("value")).ToList();
var values = table.Rows.Select(x => x[0]).ToList();
if (values.All(x => x == String.Empty))
return;
CollectionAssert.AreEquivalent(dropDownValues, values);
}
Вы могли бы немного повозиться, чтобы убедиться, что значение и текст точно совпадают, но это работает для меня.