【发布时间】:2016-11-08 07:38:36
【问题描述】:
我有:
[TextView] id:“MonthValue”文本:“11”
我想将文本作为 id 的字符串 MonthValue
【问题讨论】:
-
我需要:“11”作为字符串
标签: c# android xamarin uitest xamarin.uitest
我有:
[TextView] id:“MonthValue”文本:“11”
我想将文本作为 id 的字符串 MonthValue
【问题讨论】:
标签: c# android xamarin uitest xamarin.uitest
只需使用查询的Text 属性:
app.Query(c => c.Id("MonthValue").Text
参考:https://developer.xamarin.com/api/property/Xamarin.UITest.Queries.AppResult.Text/
【讨论】:
想要更新吉姆的答案。 app.Query 返回一个数组,所以我们不能使用
app.Query(c => c.Id("MonthValue")).Text 本身。例如,我们应该使用app.Query(c => c.Id("MonthValue"))[0].Text
【讨论】:
app.Query(c => c.Id("MonthValue").Text("11")) 应该这样做
【讨论】:
我也遇到了同样的问题,虽然我通过Repl() 命令通过调试得到了解决方案。
尝试像这样使用索引位置:
app.Query(c=>c.Id("NoResourceEntry-8"))[0].Text
类似地,你可以使用相同的类:
app.Query(c=>c.Class("LabelRenderer"))[0].Text
Class("LabelRenderer") 的查询得到 2 个结果。
所以在上面的例子中,你可以看到它给了你 2 个结果,但是你必须对特定的结果使用 index。
【讨论】: