UiAutomator RF+appium+uiautomatorviewer 定位不到 webview 里 EditText 的 xpath,并输入数据,求帮助,求分析!!!

name · 2016年04月21日 · 最后由 da 回复于 2017年03月07日 · 2016 次阅读



如图,此注册页面是 webview 里的 H5 页面

appium 信息:

info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@index='1']/android.widget.EditText[@index='1'] using XPATH with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@index='1']/android.widget.EditText[@index='1'] using XPATH with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}

RobotFramework 的错误信息:

Starting test: Test.注册
20160421 14:01:29.605 : INFO : Clicking element 'name=注册'.
20160421 14:01:34.941 : INFO : Slept 3 seconds
20160421 14:01:34.951 : INFO : Typing text '45588888455' into text field 'xpath=//android.view.View[@index='1']/android.widget.EditText[@index='1']'
20160421 14:01:36.603 : INFO :


20160421 14:01:36.604 : FAIL : ValueError: Element locator 'xpath=//android.view.View[@index='1']/android.widget.EditText[@index='1']' did not match any elements.
Ending test: Test.注册
共收到 13 条回复 时间 点赞

//android.view.View[@index='1']/android.widget.EditText[@index='1'] 无法定位到元素
直接用//android.widget.EditText[@index='1'] 能定位不到吗,android.view.View[@index='1'] 会不会定位到其他元素了

name #2 · 2016年04月21日 Author

#1 楼 @snowmaster 直接用//android.widget.EditText[@index='1'] 定位不到,因为下面那个验证码输入框也是同样的 xpath

#2 楼 @duffypace 你直接用 class 定位不就好了。在 rf+appium 群吗?可以直接找我

name #4 · 2016年04月21日 Author

#3 楼 @neyo 不在,刚研究这个不久,求带~

XPath 教程

<?xml version="1.0" encoding="UTF-8"?>
<AAA> 
  <BBB> 
    <CCC></CCC> 
    <DDD></DDD> 
  </BBB> 
</AAA>

XPath 定位 DDD 可以这样写//*[text()='兄']/following-sibling::DDD

看一下 View{手机号:} 的属性,我猜可以这样定位手机号输入框
//android.view.View[text()='手机号:']/following-sibling::android.widget.EditText

PS:RobotFramework 错误信息 markdown 排下版

#4 楼 @duffypace 138978619 加 q 群

//android.widget.EditText[1] 这样的试过了吗?

name #8 · 2016年04月22日 Author

#5 楼 @sanlengjingvv 此方法可行

name #9 · 2016年04月22日 Author

#6 楼 @neyo 已加,谢

黑水 [该话题已被删除] 中提及了此贴 08月18日 08:42

#9 楼 @duffypace 楼主解决了么

楼主解决了吗

怎么解决的,我这边是有时能通过 uiautomatorviewer 解析出元素,有时只是显示 webview

楼主解决了没,这个问题???在线等~~~

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册