Ofi*_* A. 10 xpath android appium android-uiautomator
我正在使用Appium框架测试我的Android应用程序.我有一个Android屏幕,其视图没有id(我不想添加...),所以我想使用Xpath.
这是UI Automator Viewer中屏幕的样子:

我想得到所有的相对布局(用红色标记 - 十六项)
我尝试了以下方法:
 List<WebElement> webElementslist =
 mAppDriver.findElementsByXPath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.ViewAnimator[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]");
但我没有收到任何物品.
我在网上搜索并找到了下一个xpath教程,尝试了更多选项,但又没有成功.
http://www.zvon.org/comp/r/tut-XPath_1.html#intro
非常感谢任何帮助.
现在有一些令人讨厌的错误,在Android上使用XPath来解释你所看到的行为.它们计划在1.3.1版本中修复
理想情况下,您可以查找android.widget.LinearLayout所有16 RelativeLayout秒的父级的资源ID,然后执行以下操作:
//android.widget.LinearLayout[@resource-id="foo"]/android.widget.RelativeLayout
你的详细解决方案不起作用,因为你给了其中一个布局一个位置[2].
这是固定的:
//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.ViewAnimator[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout
....请,请使用第一个解决方案.
我正在寻找使用UiAutomator定位器策略解决问题的解决方案,但还没有答案(因为.fromChild()并且.fromParent()似乎已被打破)
| 归档时间: | 
 | 
| 查看次数: | 23004 次 | 
| 最近记录: |