在 4.3 版本的三星手机上跑,有个 Button 有TextID 属性,但使用这两属性无法定位到该元素。觉得挺奇怪的,哪位朋友知道大概是什么原因呢??

Button 及其属性

设置:

capabilities.setCapability("automationName","Selendroid");
capabilities.setCapability("deviceName", "Galaxy S4");

使用 ID 定位

info: --> POST /wd/hub/session/8eedd86f-4d6b-fbf6-ab10-672ef9ab3230/element {"using":"id","value":"com.android.settings:id/action_button"}
debug: Appium request initiated at /wd/hub/session/8eedd86f-4d6b-fbf6-ab10-672ef9ab3230/element
debug: Request received with params: {"using":"id","value":"com.android.settings:id/action_button"}
debug: Proxying command to localhost:8080
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/8eedd86f-4d6b-fbf6-ab10-672ef9ab3230/element,method:POST,json:{using""
:"id","value":"com.android.settings:id/action_button"}}
debug: Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origVal
ue":"Element was not found.\nio.selendroid.exceptions.NoSuchElementException: Element was not found.\n\tat io.selendroid.server.handler.FindElement.handle(FindE
lement.java:57)\n\tat io.selendroid.server.AndroidServlet.handleRequest(AndroidServlet.java:290)\n\tat io.selendroid.server.BaseServlet.handleHttpRequest(BaseSe
rvlet.java:70)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(Net
tyHttpControl.java:62)\n\tat io.selendroid.server.inspector.InspectorServlet.handleHttpRequest(InspectorServlet.java:78)\n\tat org.webbitserver.netty.NettyHttpC
ontrol.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.
PathMatchHandler.handleHttpRequest(PathMatchHandler.java:33)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbi
tserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.DateHeaderHandler.handleHttpRequest(DateHeaderHandler.java:2
1)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpContro
l.java:62)\n\tat org.webbitserver.handler.ServerHeaderHandler.handleHttpRequest(ServerHeaderHandler.java:25)\n\tat org.webbitserver.netty.NettyHttpControl.nextH
andler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:67)\n\tat org.webbitserver.netty.NettyHttpChann
elHandler$2.run(NettyHttpChannelHandler.java:72)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)\n\tat java.util.concurren
t.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)\n\tat java.lang.Thread.run(Thread.java:841)\n"},"sessionId":"8eedd86f-4d6b-fbf6-ab10-672ef9ab3230"}
info: <-- POST /wd/hub/session/8eedd86f-4d6b-fbf6-ab10-672ef9ab3230/element 500 5257.921 ms - 2040

使用 Text 定位

info: --> POST /wd/hub/session/aa4acc67-900c-eaea-443a-e6751dd13ab8/element {"using":"link text","value":"Activate"}
debug: Appium request initiated at /wd/hub/session/aa4acc67-900c-eaea-443a-e6751dd13ab8/element
debug: Request received with params: {"using":"link text","value":"Activate"}
debug: Proxying command to localhost:8080
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/aa4acc67-900c-eaea-443a-e6751dd13ab8/element,method:POST,json:{using""
:"link text","value":"Activate"}}
debug: Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origVal
ue":"Element was not found.\nio.selendroid.exceptions.NoSuchElementException: Element was not found.\n\tat io.selendroid.server.handler.FindElement.handle(FindE
lement.java:57)\n\tat io.selendroid.server.AndroidServlet.handleRequest(AndroidServlet.java:290)\n\tat io.selendroid.server.BaseServlet.handleHttpRequest(BaseSe
rvlet.java:70)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(Net
tyHttpControl.java:62)\n\tat io.selendroid.server.inspector.InspectorServlet.handleHttpRequest(InspectorServlet.java:78)\n\tat org.webbitserver.netty.NettyHttpC
ontrol.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.
PathMatchHandler.handleHttpRequest(PathMatchHandler.java:33)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbi
tserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.DateHeaderHandler.handleHttpRequest(DateHeaderHandler.java:2
1)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpContro
l.java:62)\n\tat org.webbitserver.handler.ServerHeaderHandler.handleHttpRequest(ServerHeaderHandler.java:25)\n\tat org.webbitserver.netty.NettyHttpControl.nextH
andler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:67)\n\tat org.webbitserver.netty.NettyHttpChann
elHandler$2.run(NettyHttpChannelHandler.java:72)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)\n\tat java.util.concurren
t.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)\n\tat java.lang.Thread.run(Thread.java:841)\n"},"sessionId":"aa4acc67-900c-eaea-443a-e6751dd13ab8"}
info: <-- POST /wd/hub/session/aa4acc67-900c-eaea-443a-e6751dd13ab8/element 500 5109.430 ms - 2040
info: --> DELETE /wd/hub/session/aa4acc67-900c-eaea-443a-e6751dd13ab8 {}
debug: Appium request initiated at /wd/hub/session/aa4acc67-900c-eaea-443a-e6751dd13ab8
debug: Request received with params: {}
info: Shutting down appium session
debug: Stopping selendroid server


↙↙↙阅读原文可查看相关链接,并与作者交流