C# Xamarin UITest:有没有一种方法可以使用不区分大小写的字符串进行应用程序查询?
我有一个元素列表,我想检查列表是否包含我要查找的人名 最简单的方法是:C# Xamarin UITest:有没有一种方法可以使用不区分大小写的字符串进行应用程序查询?,c#,xamarin.uitest,C#,Xamarin.uitest,我有一个元素列表,我想检查列表是否包含我要查找的人名 最简单的方法是: app.Query(e => e.All().Id("text_name").Property("Text").Contains("Dupont") ); “text_name”是每个列表项中TextView的Id 除了有时列表中的名称可能是“dupont”或“dupont”,在这种情况下,查询将无法找到它 我查看了UITest AppQuery API,显然没有办法使用不区分大小写的字符串进行查询。因此,为了克服这
app.Query(e => e.All().Id("text_name").Property("Text").Contains("Dupont") );
“text_name”是每个列表项中TextView的Id
除了有时列表中的名称可能是“dupont”或“dupont”,在这种情况下,查询将无法找到它
我查看了UITest AppQuery API,显然没有办法使用不区分大小写的字符串进行查询。因此,为了克服这个限制,我建议您这样做:
String[] results = app.Query(e => e.All().Id("text_name").Invoke("getText"))
.Cast<String>().ToArray();
Assert.IsTrue( ArrayContainsCaseInsensitive(results, "Dupont") );
因此,为了绕过这个限制,我建议您这样做:
String[] results = app.Query(e => e.All().Id("text_name").Invoke("getText"))
.Cast<String>().ToArray();
Assert.IsTrue( ArrayContainsCaseInsensitive(results, "Dupont") );
以下是我使用的解决方案:
var result = app.Query(x => x.Marked("text_name"))
.Where(x => x.Text.Equals("dupont", StringComparison.InvariantCultureIgnoreCase));
以下是我使用的解决方案:
var result = app.Query(x => x.Marked("text_name"))
.Where(x => x.Text.Equals("dupont", StringComparison.InvariantCultureIgnoreCase));