Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get text of specific element - Xamarin UI Test

I have:

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

I want to get text as String of id MonthValue

like image 670
Żyli Avatar asked Dec 24 '22 23:12

Żyli


2 Answers

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/

like image 99
Krumelur Avatar answered Dec 26 '22 16:12

Krumelur


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

like image 29
MiddleD. Avatar answered Dec 26 '22 15:12

MiddleD.