[英]Selenium C#, IList<IWebElement> Iterate through and Assert Values
Any help would be appreciated. 任何帮助,将不胜感激。
Firstly, I'm using pageObject, and I have the following element. 首先,我正在使用pageObject,并且具有以下元素。
[FindsBy(How = How.Xpath, Using = ".//*[@id='control-content']/div/tbody/th")]
public IList<IWebElement> TableHeaders { get; set; }
In this Ilist it should collect all values within the main column header. 在此Ilist中,它应收集主列标题内的所有值。
I instantiate the class in the relevant page for script. 我在脚本的相关页面中实例化该类。
pageModule pm = new PageModule();
In the relevant page. 在相关页面中。 I call the element. 我称这个元素。
var values = pm.TableHeaders;
Then II set a list 然后我设置一个清单
List<String> nameFilters = new List<String>(){
"Name",
"Name2",
}
foreach(var value in Values){
Console.WriteLine("The value is : ") + values);
}
This is for the outputting the text in the ilist, I want to check the values match the Ilist and The string list. 这是为了在ilist中输出文本,我想检查值是否与Ilist和String列表匹配。
I want to iterate through the list of these and check that list contains these values, I know you can use LINQ to make this query simple, I just can't think of an easy idea at the moment. 我想遍历这些列表并检查列表是否包含这些值,我知道您可以使用LINQ简化此查询,此刻我想不出一个简单的主意。
Thanks 谢谢
My Solution worked... 我的解决方案有效...
var value = pm.TableHeaders;
List<string> nameFilters = new List<string>()
{
"Name",
"Name2",
};
List<string> text = value.Select(x => x.Text).Where(columnName => columnName != "").ToList();
return nameFilters.SequenceEqual(text);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.