4

I have:

[TextView] id: "MonthValue" text: "11"

I want to get text as String of id MonthValue

DaniP
  • 37,813
  • 8
  • 65
  • 74
Żyli
  • 41
  • 1
  • 3

4 Answers4

5

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/

Krumelur
  • 32,180
  • 27
  • 124
  • 263
3

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

MiddleD.
  • 315
  • 1
  • 4
  • 21
1

app.Query(c => c.Id("MonthValue").Text("11")) should do it

JimBobBennett
  • 2,149
  • 14
  • 11
  • Yes, but I have to get this value, because I can change this value by +/- . sth what should work like: String x = app.Query(c => c.Id("MonthValue").getText()) – Żyli Nov 08 '16 at 07:50
  • 1
    AppResult has a Text property, so try app.Query(c => c.Id("MonthValue")).Text. https://developer.xamarin.com/api/property/Xamarin.UITest.Queries.AppResult.Text/ – JimBobBennett Nov 08 '16 at 13:25
1

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.

Alessio
  • 3,404
  • 19
  • 35
  • 48
Amit
  • 21
  • 3