Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Xamarin UITest:有没有一种方法可以使用不区分大小写的字符串进行应用程序查询?_C#_Xamarin.uitest - Fatal编程技术网

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));