在Android本机应用程序上找不到元素

问题描述 投票:0回答:1

我尝试使用 Appium 检查器在 Android 本机应用程序上找到“立即加入”按钮元素,如下所示: enter image description here

但我无法在 Appium Inspector 上选择它 然后我将 XML 源复制到文本编辑器并尝试查找“登录”一词,但 XML 源中没有“登录”。 谁能告诉我原因以及如何找到这个元素?

这是 XML 源代码:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<hierarchy index="0" class="hierarchy" rotation="0" width="720" height="1184">
  <android.widget.FrameLayout index="0" package="com.starbucks.vn" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
    <android.widget.LinearLayout index="0" package="com.starbucks.vn" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
      <android.widget.FrameLayout index="0" package="com.starbucks.vn" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
        <android.widget.LinearLayout index="0" package="com.starbucks.vn" class="android.widget.LinearLayout" text="" resource-id="com.starbucks.vn:id/action_bar_root" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
          <android.widget.FrameLayout index="0" package="com.starbucks.vn" class="android.widget.FrameLayout" text="" resource-id="android:id/content" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
            <android.widget.FrameLayout index="0" package="com.starbucks.vn" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                  <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                    <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true" />
                    <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                      <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                        <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                          <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                            <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                  <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                    <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                      <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                        <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                          <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                            <android.widget.ScrollView index="0" package="com.starbucks.vn" class="android.widget.ScrollView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1184]" displayed="true">
                                              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,934]" displayed="true">
                                                <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,239][720,699]" displayed="true">
                                                  <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,271][688,381]" displayed="true">
                                                    <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,271][688,364]" displayed="true">
                                                      <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,271][688,355]" displayed="true">
                                                        <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,307][688,355]" displayed="true">
                                                          <android.widget.TextView index="0" package="com.starbucks.vn" class="android.widget.TextView" text="Email*" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,312][688,350]" displayed="true" />
                                                        </android.view.ViewGroup>
                                                        <android.widget.EditText index="1" package="com.starbucks.vn" class="android.widget.EditText" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="true" password="false" scrollable="false" selected="false" bounds="[32,319][688,355]" displayed="true" />
                                                      </android.view.ViewGroup>
                                                    </android.view.ViewGroup>
                                                  </android.view.ViewGroup>
                                                  <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,381][688,515]" displayed="true">
                                                    <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,405][688,498]" displayed="true">
                                                      <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,405][623,489]" displayed="true">
                                                        <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,441][623,489]" displayed="true">
                                                          <android.widget.TextView index="0" package="com.starbucks.vn" class="android.widget.TextView" text="Password*" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,446][623,484]" displayed="true" />
                                                        </android.view.ViewGroup>
                                                        <android.widget.EditText index="1" package="com.starbucks.vn" class="android.widget.EditText" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="true" password="true" scrollable="false" selected="false" bounds="[32,453][623,489]" displayed="true" />
                                                      </android.view.ViewGroup>
                                                      <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[638,405][687,479]" displayed="true">
                                                        <android.widget.ImageView index="0" package="com.starbucks.vn" class="android.widget.ImageView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[638,447][687,479]" displayed="true" />
                                                      </android.view.ViewGroup>
                                                    </android.view.ViewGroup>
                                                  </android.view.ViewGroup>
                                                  <android.view.ViewGroup index="2" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,564][688,611]" displayed="true">
                                                    <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,564][79,611]" displayed="true">
                                                      <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,564][79,611]" displayed="true">
                                                        <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,576][70,599]" displayed="true">
                                                          <android.widget.ImageView index="0" package="com.starbucks.vn" class="android.widget.ImageView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,576][70,599]" displayed="true" />
                                                        </android.view.ViewGroup>
                                                      </android.view.ViewGroup>
                                                    </android.view.ViewGroup>
                                                    <android.widget.TextView index="1" package="com.starbucks.vn" class="android.widget.TextView" text="Keep me logged in" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[103,568][351,606]" displayed="true" />
                                                  </android.view.ViewGroup>
                                                  <android.view.ViewGroup index="3" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,610][688,699]" displayed="true">
                                                    <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,659][688,699]" displayed="true">
                                                      <android.widget.TextView index="0" package="com.starbucks.vn" class="android.widget.TextView" text="Forgot password?" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,659][688,699]" displayed="true" />
                                                    </android.view.ViewGroup>
                                                  </android.view.ViewGroup>
                                                </android.view.ViewGroup>
                                                <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,699][720,934]" displayed="true" />
                                              </android.view.ViewGroup>
                                            </android.widget.ScrollView>
                                            <android.view.ViewGroup index="1" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,239]" displayed="true">
                                              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,239]" displayed="true" />
                                            </android.view.ViewGroup>
                                            <android.view.ViewGroup index="2" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,48][81,145]" displayed="true">
                                              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,48][81,145]" displayed="true">
                                                <android.widget.ImageView index="0" package="com.starbucks.vn" class="android.widget.ImageView" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,80][49,113]" displayed="true" />
                                              </android.view.ViewGroup>
                                            </android.view.ViewGroup>
                                            <android.view.ViewGroup index="3" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[517,76][720,118]" displayed="true">
                                              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[517,76][720,118]" displayed="true">
                                                <android.widget.TextView index="0" package="com.starbucks.vn" class="android.widget.TextView" text="Join now" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[549,76][687,118]" displayed="true" />
                                              </android.view.ViewGroup>
                                            </android.view.ViewGroup>
                                            <android.view.ViewGroup index="5" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,192][688,287]" displayed="true">
                                              <android.view.ViewGroup index="0" package="com.starbucks.vn" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,192][688,250]" displayed="true">
                                                <android.widget.TextView index="0" package="com.starbucks.vn" class="android.widget.TextView" text="Starbucks" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[32,192][244,250]" displayed="true" />
                                                <android.widget.TextView index="1" package="com.starbucks.vn" class="android.widget.TextView" text=" Rewards" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[244,192][439,250]" displayed="true" />
                                                <android.widget.TextView index="2" package="com.starbucks.vn" class="android.widget.TextView" text="™" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[439,192][464,230]" displayed="true" />
                                              </android.view.ViewGroup>
                                            </android.view.ViewGroup>
                                          </android.view.ViewGroup>
                                        </android.view.ViewGroup>
                                      </android.view.ViewGroup>
                                    </android.view.ViewGroup>
                                  </android.view.ViewGroup>
                                </android.view.ViewGroup>
                              </android.view.ViewGroup>
                            </android.view.ViewGroup>
                          </android.view.ViewGroup>
                        </android.view.ViewGroup>
                      </android.view.ViewGroup>
                    </android.view.ViewGroup>
                  </android.view.ViewGroup>
                </android.view.ViewGroup>
              </android.view.ViewGroup>
            </android.widget.FrameLayout>
          </android.widget.FrameLayout>
        </android.widget.LinearLayout>
      </android.widget.FrameLayout>
    </android.widget.LinearLayout>
  </android.widget.FrameLayout>
</hierarchy>

android xml xpath ui-automation appium-android
1个回答
0
投票

我认为,这应该是具有属性

android.view.ViewGroup
clickable="true"
之一,包含
android.widget.ImageView
。最好使用
uiautomatorviewer
,它允许悬停转储的屏幕截图,以确定 XML 中的关联节点。

© www.soinside.com 2019 - 2024. All rights reserved.