【发布时间】:2016-04-18 10:17:01
【问题描述】:
public static List<Hashtable> StoreSearchResult(NgWebDriver driver)
{
List<Hashtable> searchList = new List<Hashtable>();
Hashtable table = new Hashtable();
// List<SEarchResult> searchResultList = new List<SEarchResult>();
int numberofrows = driver.FindElements(By.XPath("//*[@id='contenttablegridsearchModal']/div")).Count;
for (int i = 0; i < numberofrows; i++)
{
table.Add("ID",driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[2]/div")).Text);
table.Add("Date", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[3]/div")).Text);
table.Add("Type", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[4]/div")).Text);
table.Add("Sub-Type", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[5]/div")).Text);
table.Add("Description", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[6]/div")).Text);
table.Add("Score", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[7]/div")).Text);
table.Add("Asssigned-To", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[8]/div")).Text);
table.Add("Close-Reason", driver.FindElement(By.XPath("//*[@id='row" + i + "gridsearchModal']/div[9]/div")).Text);
}
searchList.Add(table);
int sizeoftable = table.Count;
int sizeoflist = searchList.Count;
System.Console.WriteLine(sizeoftable);
System.Console.WriteLine(searchList);
return searchList;
}
我需要用 Key 迭代列表中的每个项目(具有哈希表)..
我正在使用 Foreach 进行迭代,但我没有获得传递键值的选项..
List<Hashtable> searchList = class1.StoreSearchResult(ngdriver);
foreach (var item in searchList)
{
Hashtable tablevalue= item;
}
你能帮帮我吗?
【问题讨论】: