我有一个正在测试的选择元素。我需要断言此 Select 元素中不存在带有用户指定文本的某个选项,并且还需要断言 SelectElement 中确实存在带有用户指定文本的另一个选项。
最佳答案
这会起作用:
public bool OptionListContains(SelectElement select, string expectedValue)
{
IList<IWebElement> options = select.Options;
List<string> optionsText = options.Select(a => a.Text).ToList();
return optionsText.Contains(expectedValue);
}
以防万一您在需要之前没有使用过 LINQ 查询:
使用 System.Linq;
关于c# - 通过 Selenium 检查 SelectElement 元素中是否存在选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42008989/