验证下拉选项我的脚本抛出错误,请帮助 Webdriver 和 C#

本文关键字:帮助 Webdriver 错误 出错 选项 我的 脚本 验证 | 更新日期: 2023-09-27 18:32:02

验证下拉选项 我的脚本抛出错误,请帮助 Web驱动程序和 C#

返回了两个错误;选项上应返回两个错误(for(IWebElement title:options))

public void VerifyDropdownOptions()
{
  String[] SysViews = {
  "--Select a view--",
  "Contacts being followed",
  "Contact I follow",
  "Contacts: No campaign activities in last 3 months",
  "Contacts: Responded to Campaigns in last 6 months",
  "Inactive contacts","My Connections"
};
IWebElement dropdown = FindElement(By.Id("crmGrid_SavedNewQuerySelector"));  
     SelectElement select = new SelectElement(dropdown);  
     List<IWebElement> options = select.getOptions();  
    // List<IWebElement> options = select.FindElements(By.LinkText("title"));  
     int SysOptions = SysViews.Length;
  for(IWebElement title:options)  
     {  
      Boolean match = false;
         for (int i=0; i < SysOptions; i++)
          {
              if (title.getText().equals(SysViews[i]))
                {
                match = true;
                }
          }
       Assert.True(match);
     }   
   }

验证下拉选项我的脚本抛出错误,请帮助 Webdriver 和 C#

您正在使用 C# 使用以下代码进行 foreach 循环:

foreach (IWebElement title in options)
{ 
}

:用于Java而不是C#