遇到一个问题:

两个 linearlayout 分别有三个按钮,话说怎么通过其中一个 linearlayout 上的按钮 1 定位到另一个 linearlayout 中的按钮 one?

截图如下:

布局文件如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <LinearLayout
        android:id="@+id/ll_one"
        android:layout_width="300dp"
        android:layout_height="200dp"
        android:background="#FFFF0000" >
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮1" />
        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮2" />
        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮3" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/ll_two"
        android:layout_width="300dp"
        android:layout_height="200dp"
        android:background="#A6A600" >
        <Button
            android:id="@+id/buttonone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮one" />
        <Button
            android:id="@+id/buttontwo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮two" />
        <Button
            android:id="@+id/buttonthree"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮three" />
    </LinearLayout>
</LinearLayout>

ps:已经尝试过用 findElementByAndroidUIAutomator(),但我最多只能在同一个 LinearLayout 中定位兄弟、父子元素。


↙↙↙阅读原文可查看相关链接,并与作者交流