用 python,查找 clickable 为 true 的 image,找到的结果却是所有 image,包含 false 的
el = driver.find_elements_by_xpath("//image[@clickable=true]")
for i in el:
i.get_attribute('clickable')
'true'
'false'
'true'
'true'
'true'
'true'
'true'
'true'
'true'
看到http://testerhome.com/topics/525 里用 ruby 也是类似这样查找的,是 python 的问题吗?
true 加上引号也不行
el = driver.find_elements_by_xpath("//image[@clickable='true']")
我那个只是例子, 是不起作用的. 拿到的也是全部连接.
是跟具体的实现库有关, 不过 appium1.0 应该就没这些问题了.
可以试试新的定位方法
可以试试这个
driver.element('-android uiautomator', 'new UiSelector().clickable(true)').getAttribute('name');
xpath 目前应该也是支持的了 1.0beta 版本我还没测试
@seveniruby 试了 1.0beta,用 xpath 什么都找不到....
#3 楼 @lp19851119 贴代码看看
driver.find_elements_by_xpath("//frame")
下面是 appium 的 log
跟 0.18 的实现机制好像不一样了,用了 dumpWindowHierarchy,但是传进去的 params 是{}
#5 楼 @lp19851119 你的 log 贴的不对. 还没到查找 xpath 的部分
debug: Appium request initiated at /wd/hub/session/6ebe01d4-4cff-4a0d-b74f-ed923481e1ea
debug: Request received with params: {}
info: Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"warnings":{},"desired":{"app-package":"com.qf365.JujinShip00121","app":"D:\\Download\\QF365JujinShip00121.apk","browserName":"","version":"4.3","device":"Android","app-activity":"com.qf365.JujinShip00121.SplashActivity"},"app-package":"com.qf365.JujinShip00121","app":"D:\\Download\\QF365JujinShip00121.apk","version":"4.3","device":"Android","app-activity":"com.qf365.JujinShip00121.SplashActivity"},"sessionId":"6ebe01d4-4cff-4a0d-b74f-ed923481e1ea"}
debug: 127.0.0.1 - - "GET /wd/hub/session/6ebe01d4-4cff-4a0d-b74f-ed923481e1ea HTTP/1.1" 200 785 "-" "Python-urllib/3.2"
debug: Appium request initiated at /wd/hub/session/6ebe01d4-4cff-4a0d-b74f-ed923481e1ea/elements
debug: Request received with params: {"using":"xpath","sessionId":"6ebe01d4-4cff-4a0d-b74f-ed923481e1ea","value":"//frame"}
info: Pushing command to appium work queue: ["dumpWindowHierarchy"]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"dumpWindowHierarchy","params":{}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: dumpWindowHierarchy
info: [BOOTSTRAP] [info] Returning result: {"value":true,"status":0}
debug: transferPageSourceXML command: "D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s emulator-5554 pull /data/local/tmp/dump.xml "C:\Users\ADMINI~1\AppData\Local\Temp\114319-5968-1jzdzjb.xml"
info: Responding to client with success: {"status":0,"value":[],"sessionId":"6ebe01d4-4cff-4a0d-b74f-ed923481e1ea"}
debug: 127.0.0.1 - - "POST /wd/hub/session/6ebe01d4-4cff-4a0d-b74f-ed923481e1ea/elements HTTP/1.1" 200 87 "-" "Python-urllib/3.2"
#6 楼 @seveniruby
我把下面这个 114319-5968-1jzdzjb.xml 抓了出来,里面的节点都是 Node,不知道跟这个有没有关系
debug: transferPageSourceXML command: "D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s emulator-5554 pull /data/local/tmp/dump.xml "C:\Users\ADMINI~1\AppData\Local\Temp\114319-5968-1jzdzjb.xml"
#6 楼 @seveniruby
find_elements_by_id 是直接用 find 找,而不是 dumpWindowHierarchy
Returning result 里的 value 找到的东西
#9 楼 @lp19851119 dump 是必做的, 无论怎么找都是使用 find 的
#10 楼 @seveniruby 搞不定了...用法应该是没问题的吧,难道是 beta 版的 bug
#11 楼 @lp19851119 回头我给你做个例子吧 不知道你的场景 不好下判断
我看你在 google group 也提了问题 有结果了吗
#13 楼 @seveniruby 没有呢...
#13 楼 @seveniruby 据说应该用 full class name,明天试试看
#15 楼 @lp19851119 我最近还没来得及看, 按理说不应该用全名的. 使用缩减名本来就是优势, 感觉不会倒退的