您好,这是我的第一个问题,我希望有人能帮助我:)
我想检查 table 上是否存在带有文本的项目。如果存在我想测试失败。
internal static bool IsElementWithTextInCollection(ReadOnlyCollection<IWebElement> table, string customerFieldName)
{
foreach (var item in table)
{
if (item.Text.(customerFieldName))
{
}
}
return true;
}
最佳答案
您应该检查项目中的文本 Contains 是否对结果给出 false 并打破循环。
internal static bool IsElementWithTextInCollection(
ReadOnlyCollection<IWebElement> table, string customerFieldName)
{
bool result = true;
foreach (var item in table)
{
if (item.Text.Contains(customerFieldName))
{
result = false;
break;
}
}
return result;
}
关于c# - 如果元素在表格上的元素内部有文本,则测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41056830/