question

EmilAlipiev-5934 avatar image
0 Votes"
EmilAlipiev-5934 asked RobCaplan edited

Xamarin UI testing how to get the backgound color of UI element

This code used to work like suggest on Xamarin forum but no longer seems to be working. Does anyone know how to get the background color of an item in Android?

app.Query(x => x.Id("yourButton").Invoke("getBackground").Invoke("getColor"));

When I execute it, i get error message telling me that "No such method found: getColor()"


not-supported
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Have you got the answer?

0 Votes 0 ·

Unfortunately no but something I figured out that it works on some controls with some states and some doesn't. For example it works on buttons but jot with frames or stack layouts and in list view works sometimes based on some state, not sure when exactly. Because sometimes I get error as above sometimes as integer android color code.

0 Votes 0 ·

Have you tried code: var backgroundColor = app.Query(c => c.Button(buttonName).Invoke("getBackground").Invoke("getColor")); ?

0 Votes 0 ·

0 Answers