Android 如何在UITest中检查按钮的颜色

Android 如何在UITest中检查按钮的颜色,android,xamarin,uitest,Android,Xamarin,Uitest,我正在使用Xamarin.UITest编写一个测试,我想检查特定UI按钮的颜色。从Repl中,我可以抓取如下按钮: >>> app.Query(c => c.Button()).First() Query for Button() gave 1 results. { Id => "buttonGo", Description => "android.widget.Button{b312e568 VFED..C. ........ 26,234-

我正在使用Xamarin.UITest编写一个测试,我想检查特定UI按钮的颜色。从Repl中,我可以抓取如下按钮:

>>> 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
}
不幸的是,似乎没有任何财产能给我这种颜色。有没有一种方法可以让我从按钮中获取更多信息,或者用另一种方法查询按钮的颜色


更新:由于使用Invoke的建议,我取得了一些进展。我现在尝试做以下工作:

>>> app.Query(c => c.Button("buttonGo").Invoke("getBackground"))
它将调用并返回一个后台可绘制文件,但会引发以下错误:

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
如果我调用getHeight,一切都会按预期进行,因此我在这里有点困惑:

>>> app.Query(c => c.Button("buttonGo").Invoke("getHeight"))
Query for Button("buttonGo").Invoke("getHeight") gave 1 results.
[
    [0] 80
]

您要查找的是
AppQuery.Invoke
请参阅Xamarin.UITest文档“”

更新:

我认为您不能返回复杂类型,但可以链接
Invoke
调用。我认为你的情况是:

app.WaitForElement(c=>c.按钮(“buttonGo”);
app.Query(c=>c.Button(“buttonGo”).Invoke(“getBackground”).Invoke(“getColor”);

这将返回按钮的颜色id。

不幸的是,我在调用(“getBackground”)时返回null,不确定这为什么不起作用,因为您需要强制转换才能转到
ColorDrawable
调用
getColor
方法。