您可以使用更多参数构建 Xamarin UITest 查询吗?

问题描述

在我创建通用查询和结果调用的基础页面中,为了简单起见,我有一个函数可以返回基于 Android 或 iOS 的构建查询

    ```public Query QueryById(string searchId)
    {
        Query tempQuery = null;
        if (_onAndroid)
        { tempQuery = x => x.Marked(searchId); }
        else if (_oniOS)
        { tempQuery = x => x.Id(searchId); }
        else // should never enter here
        { throw new NotSupportedException(); }

        return tempQuery;
    }```

现在我想扩展这里创建的查询,说添加一个 .Index(2) 甚至抓取该索引下的所有类以抓取原始容器中的信息集合 .Index(3).Class("LabelRenderer")

有什么方法可以进行查询并扩展它。 不是转换为字符串,然后附加所有内容,然后将其放回查询对象中。

感谢您的任何见解!

解决方法

下面的代码可以工作:

var query = app.Query(q => q.Id("searchId")
        .Descendant()
        .Index(2)
        .Class("LabelRenderer"));

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...