如何在 Xamarin UI 测试中验证 tableview 元素的字母顺序
How to validate alphabetical order of tableview elements in Xamarin UI tests
我在屏幕上返回了收款人列表,想检查它们是否按字母顺序显示。它们以以下格式显示。我想检查它们是否按 Id 排序:"beneficiary_cell_title_label"
[BeneficiaryCellPhone] id: "beneficiary_cell"
[UITableViewCellContentView]
[UILabel] id: "beneficiary_cell_title_label", label: "Aaa", text: "Aaa"
[UILabel] id: "beneficiary_cell_number_label", label: "111", text: "111"
[UITableTextAccessibilityElement] id: "beneficiary_cell", label: "Aaa, 111"
[BeneficiaryCellPhone] id: "beneficiary_cell"
[BeneficiaryCellPhone] id: "beneficiary_cell"
[UITableViewCellContentView]
[UILabel] id: "beneficiary_cell_title_label", label: "Zzz", text: "Zzz"
[UILabel] id: "beneficiary_cell_number_label", label: "222", text: "222"
[UITableTextAccessibilityElement] id: "beneficiary_cell", label: "Zzz, 222"
[BeneficiaryCellPhone] id: "beneficiary_cell"
解决了以下代码的问题
/// <summary>
/// Checks the alpha order.
/// </summary>
/// <returns><c>true</c>, if alpha order was checked, <c>false</c> otherwise.</returns>
/// <param name="query">Query.</param>
public bool CheckAlphaOrder(Func<AppQuery,AppQuery> query)
{
var list = app.Query(query);
var orderByAsc = list.OrderBy(d => d.Text);
if (list.SequenceEqual(orderByAsc))
{
return true;
}else{
return false;
}
}
我在屏幕上返回了收款人列表,想检查它们是否按字母顺序显示。它们以以下格式显示。我想检查它们是否按 Id 排序:"beneficiary_cell_title_label"
[BeneficiaryCellPhone] id: "beneficiary_cell"
[UITableViewCellContentView]
[UILabel] id: "beneficiary_cell_title_label", label: "Aaa", text: "Aaa"
[UILabel] id: "beneficiary_cell_number_label", label: "111", text: "111"
[UITableTextAccessibilityElement] id: "beneficiary_cell", label: "Aaa, 111"
[BeneficiaryCellPhone] id: "beneficiary_cell"
[BeneficiaryCellPhone] id: "beneficiary_cell"
[UITableViewCellContentView]
[UILabel] id: "beneficiary_cell_title_label", label: "Zzz", text: "Zzz"
[UILabel] id: "beneficiary_cell_number_label", label: "222", text: "222"
[UITableTextAccessibilityElement] id: "beneficiary_cell", label: "Zzz, 222"
[BeneficiaryCellPhone] id: "beneficiary_cell"
解决了以下代码的问题
/// <summary>
/// Checks the alpha order.
/// </summary>
/// <returns><c>true</c>, if alpha order was checked, <c>false</c> otherwise.</returns>
/// <param name="query">Query.</param>
public bool CheckAlphaOrder(Func<AppQuery,AppQuery> query)
{
var list = app.Query(query);
var orderByAsc = list.OrderBy(d => d.Text);
if (list.SequenceEqual(orderByAsc))
{
return true;
}else{
return false;
}
}