如何在Xamarin UI测试中验证tableview元素的字母顺序

时间:2017-05-22 12:39:51

标签: xamarin.ios automated-tests xamarin.uitest

我在屏幕上显示了收款人列表,并希望检查它们是否按字母顺序显示。它们以下面的格式显示。我想检查他们是否按照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"

1 个答案:

答案 0 :(得分:1)

解决了以下代码的问题

/// <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;
            }
        }