[英]Verify all values are in the dropdown list using selenium and specflow c#
[英]How to Verify all values from DropDown List in selenium c#
我在下拉列表中有以下值,我需要非常在下拉列表中的每個值。
{“服務顧問”、“DLBO 開發人員”、“管理員代理”、“團隊負責人”、“經理”、“CV 委托人”、“CV 代理”、“取證代理”};
請提出同樣的方法。
您可以將值存儲到列表中,並將其與列表或 json 文件中保存的現有數據進行比較
var expectedDdOptions = new string[] { "Service Consultant", "DLBO Developer", "Admin Agent", "Team Leader", "Manager", "CV Mandator", "CV Agent", "Forensics Agent" };
var ActualDdOptions = new SelectElement(driver.FindElementById("YourDropdownLocatorId")).Options; //SelectElement class comes from OpenQA.Selenium.Support.UI namespace
Assert.AreEqual(expectedDdOptions.Length, ActualDdOptions.Count());
var invalidOptInDd = from e in ActualDdOptions
where !expectedDdOptions.Contains(e.Text)
select e;
Assert.IsEmpty(invalidOptInDd,"Invalid options in dropdown - " + invalidOptInDd);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.