无法在 Appium 中使用 xpath 定位元素 [英] Unable to locate element using xpath in Appium

查看:47
本文介绍了无法在 Appium 中使用 xpath 定位元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用 xpath 识别元素.附上相同的屏幕截图.我想使用

I am unable to identify an element using xpath. Attaching the screen shot of the same. I want to identify the list of elements with the tag <android.widget.LinearLayout> under <android.widget.ListView> and I have used the XPath expression:

//android.widget.ListView/android.widget.LinearLayout

This returns all the elements only from the 1st node and not the elements under <android.widget.LinearLayout>.

Can some body help me out? Thanks in advance.

解决方案

To recursively search all elements under each of the <android.widget.LinearLayout> you want this as your xpath:

xpath = '//android.widget.ListView/android.widget.LinearLayout/*'

But be careful! This is a VERY heavy operation. In your screenshot, it looks that each one of your cells has atleast 9-10 elements per row! Asking Appium for all of those elements will kill your performance.

I suggest doing something like:

xpath = '//android.widget.ListView/android.widget.LinearLayout//class_you_want'

Seriously though, I warn you against doing the first method. You should ask yourself if you only want the links on the page, or text, etc etc, and then use the second xpath finding method.

Also, read the xpath documentation for more information

这篇关于无法在 Appium 中使用 xpath 定位元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆