首页 > 解决方案 > 如何在清单中选择多个值?

问题描述

我想从测试数据中选择清单模式上的多个值。CS。我收到以下错误我做错了什么?

Error   CS1950  The best overloaded Add method 'List<string>.Add(string)' for the collection initializer has some invalid arguments.
Severity    Code    Description Project File    Line    Suppression State
Error   CS1503  Argument 1: cannot convert from 'string[]' to 'string'

这些是我的代码

Creating a generic  method to select multiple values in the checklist 

 

   public ChecklistModal SelectMultipleItemsInChecklist(List<string> value)
   {
      foreach (var v in value)
      {
           IWebElement item = Driver.Instance.FindElement(By.XPath("//input[@tmpname='" + v + "']"));
           item.Click();
       }

          return this;
    }

调用方法


  public Page SelectMultipleDispatch(List<string> multiFactors)
  { 
           
         .SelectMultipleItemsInChecklist(multiFactors)
         .ClickSave()
            
          return this;
   }

测试数据。CS

 
public static string[] dispatchFactors = { "Caller (Uncooperative)", "Communication Specialist"}

去测试


TestPage.Page.SelectMultipleDispatch(new List<string> { Data.dispatchFactors });

标签: c#selenium

解决方案


推荐阅读