app 封装 H5 应用,获取到了 content-desc 后 click 没有响应
a = self.driver.find_element_by_xpath('//android.view.View[contains(@content-desc,"海金社第2期")]')
#a=self.driver.find_element_by_xpath('//android.webkit.WebView[contains(@content-desc,"投资列表")]/android.view.View[2]/android.widget.ListView[1]/android.view.View[1]')
#print a.get_attribute('name')
sleep(3)
a.click()
页面布局如下
日志:
> info: <-- POST /wd/hub/session/b4d7a4da-35f1-479b-a60c-195f9515fb3a/element/1/click 200 287.994 ms - 76 {"status":0,"value":true,"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a"}
> info: --> POST /wd/hub/session/b4d7a4da-35f1-479b-a60c-195f9515fb3a/element {"using":"xpath","sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a","value":"//android.view.View[contains(@content-desc,\"娴烽噾绀剧2鏈焅")]"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[contains(@content-desc,\"娴烽噾绀剧2鏈焅")]","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[contains(@content-desc,\"娴烽噾绀剧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.view.View[contains(@content-desc,"娴烽噾绀剧2鏈?)] using XPATH with the contextId: multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=4]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"2"}}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"2"},"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a"}
> info: <-- POST /wd/hub/session/b4d7a4da-35f1-479b-a60c-195f9515fb3a/element 200 129.238 ms - 87 {"status":0,"value":{"ELEMENT":"2"},"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a"}
> info: --> POST /wd/hub/session/b4d7a4da-35f1-479b-a60c-195f9515fb3a/element/2/click {"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a","id":"2"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"2"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a"}
> info: <-- POST /wd/hub/session/b4d7a4da-35f1-479b-a60c-195f9515fb3a/element/2/click 200 3126.151 ms - 76 {"status":0,"value":true,"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a"}
> info: --> POST /wd/hub/session/b4d7a4da-35f1-479b-a60c-195f9515fb3a/touch/perform {"sessionId":"b4d7a4da-35f1-479b-a60c-195f9515fb3a","actions":[{"action":"longPress","options":{"y":500,"x":500,"duration":500}},{"action":"release","options":{}}]}
> info: [debug] Pushing command to appium work queue: ["element:touchLongClick",{"x":500,"y":500,"duration":500}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchLongClick","params":{"x":500,"y":500,"duration":500}}
尝试了 tap 也没有效果
self.driver.tap([(500, 500), ],500)
sleep(3)
self.driver.tap([(400, 600), ],500)