Appium appium+android+ruby 用 id 定位的方式

soul · 2014年02月21日 · 最后由 qiuqiu 回复于 2014年06月23日 · 1854 次阅读

看介绍说定位方式 id 映射到了 name 下,于是尝试用 find_element(:name, "@id") 这样的方式去定位,为什么会提示找不到元素呢。。

共收到 6 条回复 时间 点赞

直接 id 就可以了 不用 @

find_element(:name, "@id")
是用 by name 定位吧?
用 id 应该是 find_element_by_id(python),好像 appium 用不了 by id 定位吧?
请纠正。

#2 楼 @532589730 4.3 以上的系统支持. 官方文档中说的 @hyzs25

#3 楼 @seveniruby 验证了 4.4 的 好似不可以哦,debug: Appium request initiated at /wd/hub/session/1bd437bc-937f-4984-b598-07d56
dee09f0/element
debug: Request received with params: {"using":"id","value":"btnSearchOnTitle"}
info: Pushing command to appium work queue: ["find",{"strategy":"id","selector":
"btnSearchOnTitle","context":"","multiple":false}]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"find","
params":{"strategy":"id","selector":"btnSearchOnTitle","context":"","multiple":f
alse}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: find
info: [BOOTSTRAP] [debug] Finding btnSearchOnTitle using ID with the contextId:

info: [BOOTSTRAP] [info] Returning result: {"value":"Could not find an element u
sing supplied strategy. ID btnSearchOnTitle doesn't exist as text or content d
esc.","status":13}
info: Responding to client with error: {"status":13,"value":{"message":"An unkno
wn server-side error occurred while processing the command.","origValue":"Could
not find an element using supplied strategy. ID btnSearchOnTitle doesn't exist
as text or content desc."},"sessionId":"1bd437bc-937f-4984-b598-07d56dee09f0"}
POST /wd/hub/session/1bd437bc-937f-4984-b598-07d56dee09f0/element 500 6208ms - 3
08b

#3 楼 @seveniruby 我用 by_id 也一直报错,请问你找到解决办法了么

#5 楼 @qiuqiu 解决了,应该是 el = driver.find_element_by_id('com.example.test:id/num6')

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