iOS 测试 关于 appium+selenium 查找元素的问题

TIANMAOTAO · 2016年10月25日 · 最后由 TIANMAOTAO 回复于 2016年10月27日 · 1132 次阅读

描述:

表视图上一共有三个组,每个组的头视图上有个 button,点击 button 显示组下面的单元格。
我尝试过通过路径,name,以及 ID 查找组上面的 button,每次运行脚本的时候,点击这几个按钮会偶尔出错。
关于查找元素我封装了一个框架,其他地方也是用的这个框架,但是其它地方都没错,就这个地方会出错。
页面截图如下:


日志如下:
Connected to pydev debugger (build 162.1628.8)
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1556, in
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 940, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/Hexin/Desktop/iHexin/0000.py", line 84, in
test_search(driver)
File "/Users/Hexin/Desktop/iHexin/0000.py", line 28, in test_search
guzhiqihuo_gengduo_page.shangzheng50.click()
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 72, in click
self._execute(Command.CLICK_ELEMENT)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
return self._parent.execute(command, params)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command.

共收到 7 条回复 时间 点赞

各位大神快过来帮帮小白吧😭

An unknown server-side error occurred while processing the command.

你不给 server side 的 error ,看不出啥。。。

3楼 已删除

#3 楼 @LIUTIANTIAN 你要发你出错的时候的对应服务端日志。上面这些日志都是心跳包,只是不断重复,和你的错误没啥关系。

建议看下 Appium 报错后查错指南 ,对 appium 的服务器日志有个大致了解。

PS:请遵守 markdown 格式,代码和日志使用代码块格式。

#4 楼 @chenhengjie123

info: [debug] Socket data received (39 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"18"}}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"18"},"sessionId":"75c16db0-6c21-4405-96d5-5439c49a5660"}
info: <-- POST /wd/hub/session/75c16db0-6c21-4405-96d5-5439c49a5660/element 200 1031.568 ms - 88 {"status":0,"value":{"ELEMENT":"18"},"sessionId":"75c16db0-6c21-4405-96d5-5439c49a5660"}
info: --> POST /wd/hub/session/75c16db0-6c21-4405-96d5-5439c49a5660/element/18/click {"sessionId":"75c16db0-6c21-4405-96d5-5439c49a5660","id":"18"}
info: [debug] Pushing command to appium work queue: "au.tapById('18')"
info: [debug] Sending command to instruments: au.tapById('18')

info: [debug] [INST] 2016-10-26 07:41:18 +0000 Debug: Got new command 44 from instruments: au.tapById('18')

info: [debug] [INST] 2016-10-26 07:41:18 +0000 Debug: evaluating au.tapById('18')

info: [debug] [INST] 2016-10-26 07:41:18 +0000 Debug: UIATableGroup.tap()

info: [debug] [INST] 2016-10-26 07:41:18 +0000 Debug: UIATableGroup could not be tapped

info: [debug] Socket data received (58 bytes)

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":13,"value":"elementId 18 could not be tapped"}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"elementId 18 could not be tapped"},"sessionId":"75c16db0-6c21-4405-96d5-5439c49a5660"}

info: <-- POST /wd/hub/session/75c16db0-6c21-4405-96d5-5439c49a5660/element/18/click 500 1408.616 ms - 201 

info: [debug] [INST] 2016-10-26 07:41:18 +0000 Error: VerboseError: elementId 18 could not be tapped

info: [debug] [INST] 2016-10-26 07:41:18 +0000 Error: Error during eval: [native code]
       file:///Applications/Appium.app/Contents/Resources/node_modules/appium/3F267102-DE72-4247-A39B-09859DF4ABE7/bootstrap-5923cadea0343e3f.js:711:30
tapById@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/3F267102-DE72-4247-A39B-09859DF4ABE7/bootstrap-5923cadea0343e3f.js:1100:42
eval code
eval@[native code]
startProcessing@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/3F267102-DE72-4247-A39B-09859DF4ABE7/bootstrap-5923cadea0343e3f.js:2710:30
bootstrap@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/3F267102-DE72-4247-A39B-09859DF4ABE7/bootstrap-5923cadea0343e3f.js:2778:31
global code@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/3F267102-DE72-4247-A39B-09859DF4ABE7/bootstrap-5923cadea0343e3f.js:2787:10

#5 楼 @LIUTIANTIAN 找到了一个关键错误日志:

elementId 18 could not be tapped

你试下获取元素的坐标,看找到的元素对不对?如果确认确实是这个元素的话,可以采用先获取坐标,然后直接点击坐标的形式操作。

webVIEW 应该获取这个页面的所有 源码信息, 从里面再定位元素

#6 楼 @chenhengjie123
谢谢大神,可以了,使用你说的这种方式,目前运行都没问题的。👍

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