I have:
[TextView] id: "MonthValue" text: "11"
I want to get text as String of id MonthValue
Just use the query's Text
property:
app.Query(c => c.Id("MonthValue").Text
Reference: https://developer.xamarin.com/api/property/Xamarin.UITest.Queries.AppResult.Text/
Want to update Jim's answer. app.Query return an array, so we can not use
app.Query(c => c.Id("MonthValue")).Text
as itself. We should use app.Query(c => c.Id("MonthValue"))[0].Text
for example
app.Query(c => c.Id("MonthValue").Text("11"))
should do it
I was also stuck in the same problem, though I got the solution via debug through Repl()
command.
Try to use with index position like this:
app.Query(c=>c.Id("NoResourceEntry-8"))[0].Text
similarly you can use class for same:
app.Query(c=>c.Class("LabelRenderer"))[0].Text
Query for Class("LabelRenderer")
gave 2 results.
So in the above example, you can see it gave you 2 results but you have to use index for a particular result.