I'm writing a test using Xamarin.UITest and I want to examine the coloor of a specific UI button. From the Repl I can grab the button like this:
>>> app.Query(c => c.Button()).First()
Query for Button() gave 1 results.
{
Id => "buttonGo",
Description => "android.widget.Button{b312e568 VFED..C. ........ 26,234-454,314 #7f060033 app:id/buttonGo}",
Rect => {
Width => 428,
Height => 80,
X => 26,
Y => 328,
CenterX => 240,
CenterY => 368
},
Label => null,
Text => "Go!",
Class => "android.widget.Button",
Enabled => true
}
Unfortunately there doesn't seem to be any property that will give me the colour. Is there a way for me to pull more info from the button or another way to query that I could use to find the button color?
Update: So I'm making some progress, thanks to the recommendation to use Invoke. I'm now trying to do the following:
>>> app.Query(c => c.Button("buttonGo").Invoke("getBackground"))
Which should call getBackground and return me a background drawable but instead throws the following error:
Ignoring failed json serialisation of result of Query for Button("buttonGo").Invoke("getBackground"). Value was never requested
Query for Button("buttonGo").Invoke("getBackground") gave no results.
null
If I call getHeight everything works as expected so I'm a bit baffled here:
>>> app.Query(c => c.Button("buttonGo").Invoke("getHeight"))
Query for Button("buttonGo").Invoke("getHeight") gave 1 results.
[
[0] 80
]