appium Server 版本: 1.3.4.1
代码如下:
String elementsNeedToFind = "autotest-IP-DVR";
driver.findElements(By.name(elementsNeedToFind)).isEmpty()
日志如下:
> info: --> POST /wd/hub/session/a0b028fb-1375-44cb-a988-d32adc5e149b/elements {"using":"name","value":"autotest-IP-DVR"}
> info: [debug] Waiting up to 2000ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId: multiple: true
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
> info: [debug] Waited for 114ms so far
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId: multiple: true
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
> info: [debug] Waited for 698ms so far
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId: multiple: true
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
> info: [debug] Waited for 1465ms so far
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId: multiple: true
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
> info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
> info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
> info: [debug] Condition unmet after 2287ms. Timing out.
截图如下:
现象:执行的时候偶尔会出现无法定位到这个元素,结果 isEmpty() 为 true,但页面上这个元素是存在的。
求大神指点!!