Appium appium+python 切入 webview 时报错 Chromedriver: Error: An unknown server-side error occurred while processing the command. 换成原生控件登录时使用 clear 然后 send_keys 实现账号密码输入时又会先在文本框点击 2 次,在第 3 次点击时才会执行输入,导致循环输入时第二次输入参数错误

小小测试 · 2017年08月26日 · 最后由 小小测试 回复于 2017年08月31日 · 1511 次阅读

因为我的 app 是混合的,可以直接用原生控件登录,也可以进入 webview 再登录;如果先进入 webview 再登录的话,不知道为什么运行脚本时每次运行到切入 webview 时就有 80% 概率报以下错误:(只有偶尔时才能运行正常);当正常进入 webview 后调用 send_keys 可以正常输入。

> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.chang.cloudtrip","androidUseRunningApp":true,"androidDeviceSerial":"127.0.0.1:62001"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"8cbf6d90c58f490ab85fad251dbc5519","status":13,"value":{"message":"unknown error: Device 127.0.0.1:62001 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.chang.cloudtrip","androidUseRunningApp":true,"androidDeviceSerial":"127.0.0.1:62001"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"5c2ecabd6d721e52429e9202c906a2da","status":13,"value":{"message":"unknown error: Device 127.0.0.1:62001 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.chang.cloudtrip","androidUseRunningApp":true,"androidDeviceSerial":"127.0.0.1:62001"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"da4c6824365929d94ccfc0199e0e70af","status":13,"value":{"message":"unknown error: Device 127.0.0.1:62001 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.chang.cloudtrip","androidUseRunningApp":true,"androidDeviceSerial":"127.0.0.1:62001"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"c080819aa6c300568b3ca4101d6ee2aa","status":13,"value":{"message":"unknown error: Device 127.0.0.1:62001 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514...
> info: Chromedriver: Changed state to 'stopped'
> warn: Chromedriver for context WEBVIEW_com.chang.cloudtrip stopped unexpectedly
> warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring
> error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
> error: Chromedriver: Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device 127.0.0.1:62001 is not online
>   (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64))
>     at JWProxy.command$ (lib/proxy.js:133:15)

如果我直接用原生控件登录,不切入 webview;代码就不会报以上错误。但是又出现调用 clear 和 send_keys 实现账号密码输入时会先在文本框点击 2 次,在第 3 次点击时才会执行输入,因此在循环输入时,后面的输入会先点击两次,此时光标会点击到参数的中间部分(比如输入 1234567 后,再次输入 abcde 时会先把光标点击到 1 和 2 之间,然后从 1 后面开始输入。导致输入的参数多了个 1(变成了 1abcde);

我试了去掉 clear,直接 send_keys 也一样会点击到第 3 次才输入(注:我直接写一个简单的输入,不使用任何封装或者调用其他方法仍存在该问题),不知道哪位大神遇到过该问题或知道原因。麻烦帮忙看看,该怎么解决啊。实在不知道该怎么办了,困扰好久了。网上也没搜到该问题
换了其他 app 仍存在调用 send_keys 时多次点击再输入的问题

以下是关键位置的输入代码和 appium 日志:

appium 日志:

 info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.LinearLayout[contains(@index,3)]","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.LinearLayout[contains(@index,3)]","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.LinearLayout[contains(@index,3)] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Could not find an element using supplied strategy. ","status":7}
info: [debug] Condition unmet after 29ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Could not find an element using supplied strategy. "},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 65.305 ms - 230 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"xpath","value":"//android.widget.EditText[contains(@index,2)]"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.EditText[contains(@index,2)]","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.EditText[contains(@index,2)]","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.EditText[contains(@index,2)] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"9"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"9"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 200 79.003 ms - 87 {"status":0,"value":{"ELEMENT":"9"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element/9/value {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","value":["1","5","8","8","4","6","8","6","3","5","5"],"id":"9"}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"9","text":"15884686355","replace":false,"unicodeKeyboard":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"9","text":"15884686355","replace":false,"unicodeKeyboard":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: 15884686355
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element/9/value 200 6009.342 ms - 76 {"status":0,"value":true,"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"xpath","value":"//android.widget.EditText[contains(@index,3)]"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.EditText[contains(@index,3)]","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.EditText[contains(@index,3)]","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.EditText[contains(@index,3)] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText, INSTANCE=1]
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"10"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 200 27.095 ms - 88 {"status":0,"value":{"ELEMENT":"10"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"10"},"status":0}
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element/10/value {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","value":["d","1","2","3","4","5","6","7"],"id":"10"}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"10","text":"d1234567","replace":false,"unicodeKeyboard":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"10","text":"d1234567","replace":false,"unicodeKeyboard":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: d1234567
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element/10/value 200 6006.277 ms - 76 {"status":0,"value":true,"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: --> GET /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/window/current/size {}
info: [debug] Pushing command to appium work queue: ["getDeviceSize"]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDeviceSize","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDeviceSize
info: [debug] Responding to client with success: {"status":0,"value":{"width":720,"height":1280},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- GET /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/window/current/size 200 8.495 ms - 99 {"status":0,"value":{"width":720,"height":1280},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"width":720,"height":1280},"status":0}
info: --> GET /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/window/current/size {}
info: [debug] Pushing command to appium work queue: ["getDeviceSize"]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDeviceSize","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDeviceSize
info: [debug] Responding to client with success: {"status":0,"value":{"width":720,"height":1280},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- GET /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/window/current/size 200 3.636 ms - 99 {"status":0,"value":{"width":720,"height":1280},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"width":720,"height":1280},"status":0}
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 50ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 51.061 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 82ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 84.224 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 535ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 538.762 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 71ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 72.034 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 16ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 16.750 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 16ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 17.586 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 62ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 62.818 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 28ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 28.403 ms - 195 
info: --> POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element {"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f","using":"id","value":"com.chang.cloudtrip:id/safecenter"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.chang.cloudtrip:id/safecenter","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.chang.cloudtrip:id/safecenter using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.chang.cloudtrip:id/safecenter]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 61ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"f675851b-eea5-4743-bcf5-49255d1cce2f"}
info: <-- POST /wd/hub/session/f675851b-eea5-4743-bcf5-49255d1cce2f/element 500 62.969 ms - 195
共收到 5 条回复 时间 点赞

如果我直接用原生控件登录,不切入 webview;代码就不会报以上错误。但是又出现调用 clear 和 send_keys 实现账号密码输入时会先在文本框点击 2 次,在第 3 次点击时才会执行输入,因此在循环输入时,后面的输入会先点击两次,此时光标会点击到参数的中间部分(比如输入 1234567 后,再次输入 abcde 时会先把光标点击到 1 和 2 之间,然后从 1 后面开始输入。导致输入的参数多了个 1(变成了 1abcde);

遇到输入框的问题,我通常会采用 shell 和 appium 结合的方式。用 appium 拿到元素的坐标,用 shell 来点击和输入。

小小测试 PageObject+Python+Appium 中提及了此贴 08月27日 13:42
恒温 回复

好的,谢谢;我这个问题换个 app 还是存在,不知道是不是环境哪里出问题了,想找到根源解决掉

求助!求助!大神在哪里

恒温 回复

问一下,用 shell 点击输入的话,是不是只支持坐标

恒温 回复

有没有输入的代码参考下,对这个不熟,谢谢

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