51Testing软件测试论坛
标题: 执行 driver.findElements (By.name ().isEmpty () 方法-偶尔会出现页面存在该元素... [打印本页]
作者: 测试积点老人 时间: 2019-8-22 11:08
标题: 执行 driver.findElements (By.name ().isEmpty () 方法-偶尔会出现页面存在该元素...
执行 driver.findElements (By.name ().isEmpty () 方法-偶尔会出现页面存在该元素却无法获取的现象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.
复制代码截图如下:
[attach]126222[/attach]
现象:执行的时候偶尔会出现无法定位到这个元素,结果isEmpty()为true,但页面上这个元素是存在的。
求大神指点!!
作者: qqq911 时间: 2019-8-23 10:38
加个等待时间
作者: libingyu135 时间: 2019-8-23 11:43
不知
作者: litingting0214 时间: 2019-8-23 11:45
可能是上一个页面还没有加载完,直接获取页面上的东西会获取不到,加一个2s的等待时间,应该可以解决
作者: jingzizx 时间: 2019-8-23 12:25
等待是否出现
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |